{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Dataview\n",
    "\n",
    "## 介绍\n",
    "dataview可视为一个基于pandas实现的的针对因子场景的数据库,方便因子的设计实现。通过dataview，可以快捷的调取数据，并在数据集上做运算以生成新的数据集。详细描述见[官方用户手册-数据视图](https://www.quantos.org/jaqs/doc.html)\n",
    "\n",
    "## DataView做什么\n",
    "将频繁使用的DataFrame操作自动化，使用者操作数据时尽量只考虑业务需求而不是技术实现：\n",
    "\n",
    "- 1.根据字段名，自动从不同的数据api获取数据\n",
    "- 2.按时间、标的整理对齐（财务数据按发布日期对齐）\n",
    "- 3.在已有数据基础上，添加字段、加入自定义数据或根据公式计算新数据\n",
    "- 4.数据查询\n",
    "- 5.本地存储"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据下载\n",
    "dataview目前可以通过jaqs官方提供的免费数据源直接从网络获取行情数据和参考数据\n",
    "\n",
    "*** 步骤: ***\n",
    "\n",
    "- 1.配置数据下载的tcp地址(data_config)--使用jaqs官方提供的免费数据源需要提前去官网注册账号,方可使用\n",
    "- 2.创建DataView和DataService\n",
    "- 3.配置待请求的数据参数(props)\n",
    "- 4.数据下载(prepare_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import warnings\n",
    "warnings.filterwarnings('ignore')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Begin: DataApi login 18566262672@tcp://data.quantos.org:8910\n",
      "    login success \n",
      "\n",
      "Initialize config success.\n"
     ]
    }
   ],
   "source": [
    "from jaqs_fxdayu.data import DataView\n",
    "from jaqs_fxdayu.data import RemoteDataService # 远程数据服务类\n",
    "\n",
    "# step 1 其中，username password分别对应官网注册的账号和序列号\n",
    "data_config = {\n",
    "\"remote.data.address\": \"tcp://data.quantos.org:8910\",\n",
    "\"remote.data.username\": \"18566262672\",\n",
    "\"remote.data.password\": \"eyJhbGciOiJIUzI1NiJ9.eyJjcmVhdGVfdGltZSI6IjE1MTI3MDI3NTAyMTIiLCJpc3MiOiJhdXRoMCIsImlkIjoiMTg1NjYyNjI2NzIifQ.O_-yR0zYagrLRvPbggnru1Rapk4kiyAzcwYt2a3vlpM\"\n",
    "}\n",
    "\n",
    "# step 2\n",
    "ds = RemoteDataService()\n",
    "ds.init_from_config(data_config)\n",
    "dv = DataView()\n",
    "\n",
    "# step 3\n",
    "props = {'start_date': 20170501, 'end_date': 20171001, 'universe':'000300.SH',\n",
    "         'fields': \"pb,pe,total_oper_rev,oper_exp,sw1\",\n",
    "         'report_type':'408003000',\n",
    "         'freq': 1}\n",
    "\n",
    "dv.init_from_config(props, ds)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Query data...\n",
      "Query data - query...\n",
      "NOTE: price adjust method is [post adjust]\n",
      "当前请求daily...\n",
      "{'adjust_mode': None, 'fields': 'trade_status,open,low,close,trade_date,symbol,vwap,open_adj,vwap_adj,low_adj,close_adj,high,high_adj'}\n",
      "当前请求daily...\n",
      "{'adjust_mode': 'post', 'fields': 'open,low,close,vwap,high,symbol,trade_date'}\n",
      "当前请求query_lb_dailyindicator...\n",
      "{'fields': 'symbol,pe,trade_date,pb'}\n",
      "WARNING: some data is unavailable: \n",
      "    At fields \n",
      "Query data - daily fields prepared.\n",
      "Query data - quarterly fields prepared.\n",
      "Query instrument info...\n",
      "Query adj_factor...\n",
      "Query benchmark...\n",
      "Query benchmar member info...\n",
      "Query groups (industry)...\n",
      "Field [trade_status] is overwritten.\n",
      "Data has been successfully prepared.\n"
     ]
    }
   ],
   "source": [
    "# stp4\n",
    "dv.prepare_data()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**props参数**\n",
    "\n",
    "|字段|缺省值|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|symbol |不可缺失，symbol与universe二选一  |string |标的代码，多标的以','隔开，如'000001.SH,600300.SH'|\n",
    "|universe |不可缺失，symbol与universe二选一  |string |指数代码（股票池），将该些指数的成员数据全部请求，多标的以','隔开，如沪深300成分股+上证50成分股'000300.SH,000016.SH'|\n",
    "|benchmark |默认为universe中设置的第一个指数 |string |基准，可以为指数代码或个股代码，单标的|\n",
    "|start_date |不可缺省 |int |开始日期|\n",
    "|end_date |不可缺省 |int |结束日期|\n",
    "|fields |不可缺省 |string |数据字段，多字段以','隔开，如'open,close,high,low'|\n",
    "|freq |1 |int |数据类型，目前只支持1，表示日线数据|\n",
    "|all_price |True |bool |是否默认下载所有日线行情相关数据。默认下载|\n",
    "|adjust_mode |'post' |string |行情数据复权类型，默认后复权,目前只支持后复权|\n",
    "|report_type |'408001000' |string |财报类型。财报类型共有以下几类：'408001000':合并报表；'408002000':合并报表（单季度）；'408003000':合并报表（单季度调整）；'408004000':合并报表（调整）；'408005000':合并报表（更正前）；'408006000':母公司报表；'408007000':母公司报表（单季度）；'408008000':母公司报表（单季度调整）；'408009000':母公司报表（调整）；'408010000':母公司报表(更正前)|"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### fields可选字段查询方式\n",
    "dataview的底层数据api提供了字段的文档，可供查阅。目前,只提供了**A股财务数据**的相关字段文档。更过品种、行情相关字段文档请关注[jaqs官方数据文档](http://jaqs.readthedocs.io/zh_CN/latest/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('username: 18566262672', '0,')"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from jaqs_fxdayu.data import DataApi\n",
    "\n",
    "api = DataApi(data_config[\"remote.data.address\"]) # 传入连接到的远端数据服务器的tcp地址\n",
    "api.login(username=data_config[\"remote.data.username\"],\n",
    "          password=data_config[\"remote.data.password\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### help.apiList\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 查询可选字段的类别\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>api</th>\n",
       "      <th>comment</th>\n",
       "      <th>name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>jy.balanceSheet</td>\n",
       "      <td>资产负债表</td>\n",
       "      <td>资产负债表</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>jy.cashFlow</td>\n",
       "      <td>现金流量表</td>\n",
       "      <td>现金流量表</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>jy.income</td>\n",
       "      <td>利润表</td>\n",
       "      <td>利润表</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>jy.qincome</td>\n",
       "      <td>季度利润表</td>\n",
       "      <td>季度利润表</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>jz.instrumentInfo</td>\n",
       "      <td>证券基本信息</td>\n",
       "      <td>证券基础信息</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>jz.secTradeCal</td>\n",
       "      <td>交易日历</td>\n",
       "      <td>交易日历</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>lb.balanceSheet</td>\n",
       "      <td>资产负债表</td>\n",
       "      <td>资产负债表</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>lb.cashFlow</td>\n",
       "      <td>现金流量表</td>\n",
       "      <td>现金流量表</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>lb.dcCoinInfo</td>\n",
       "      <td>数字货币信息</td>\n",
       "      <td>数字货币信息</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>lb.dcDaily</td>\n",
       "      <td>数字货币日行情</td>\n",
       "      <td>数字货币日行情</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>lb.dcExchangeInfo</td>\n",
       "      <td>十大数字货币交易所信息</td>\n",
       "      <td>数字货币交易所信息</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>lb.dcTradeInfo</td>\n",
       "      <td>数字货币交易标的信息</td>\n",
       "      <td>数字货币交易标的信息</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>lb.hkSecDailyIndicator</td>\n",
       "      <td>港股日行情指标</td>\n",
       "      <td>港股日行情指标</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>lb.income</td>\n",
       "      <td>利润表</td>\n",
       "      <td>利润表</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>lb.indexCons</td>\n",
       "      <td>指数成份股</td>\n",
       "      <td>指数成份股</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>lb.indexInfo</td>\n",
       "      <td>指数基本信息</td>\n",
       "      <td>指数基本信息</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>lb.industryType</td>\n",
       "      <td>行业代码表</td>\n",
       "      <td>行业代码表</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>lb.mfDailyPerform</td>\n",
       "      <td>公募基金行情表现</td>\n",
       "      <td>公募基金行情表现</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>lb.mfNav</td>\n",
       "      <td>公募基金净值</td>\n",
       "      <td>公募基金净值</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>lb.secAdjFactor</td>\n",
       "      <td>复权因子</td>\n",
       "      <td>复权因子</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>lb.secArchives</td>\n",
       "      <td>公司概况</td>\n",
       "      <td>公司概况</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>lb.secDailyIndicator</td>\n",
       "      <td>股票每日指标</td>\n",
       "      <td>股票每日指标</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>lb.secDailyPerform</td>\n",
       "      <td>股票行情表现</td>\n",
       "      <td>股票行情表现</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>lb.secDividend</td>\n",
       "      <td>分红送股</td>\n",
       "      <td>分红送股表</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>lb.secFinIndicators</td>\n",
       "      <td>财务数据指标</td>\n",
       "      <td>财务数据指标</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>lb.secFrozenPledger</td>\n",
       "      <td>股东股权冻结和质押</td>\n",
       "      <td>股东股权冻结和质押</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>lb.secHolderNumber</td>\n",
       "      <td>股东户数</td>\n",
       "      <td>股东户数</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>lb.secHoldingStats</td>\n",
       "      <td>股东持股统计</td>\n",
       "      <td>股东持股统计</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>lb.secIEXDaily</td>\n",
       "      <td>美股公司日行情</td>\n",
       "      <td>美股公司日行情</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>lb.secIEXEps</td>\n",
       "      <td>美股公司每股收益指标</td>\n",
       "      <td>美股公司每股收益指标</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>lb.secIEXFinIndex</td>\n",
       "      <td>美股公司财务报表指标</td>\n",
       "      <td>美股公司财务报表指标</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>lb.secIEXSymbol</td>\n",
       "      <td>美股公司股票列表</td>\n",
       "      <td>美股公司股票列表</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>lb.secIndustry</td>\n",
       "      <td>行业分类信息</td>\n",
       "      <td>行业分类</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>lb.secMainHolders</td>\n",
       "      <td>股东名单</td>\n",
       "      <td>股东名单</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>lb.secNewestFinIndex</td>\n",
       "      <td>A股公司最新财务指标</td>\n",
       "      <td>A股公司最新财务指标</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>lb.secNewestShareStru</td>\n",
       "      <td>最新公司股本结构</td>\n",
       "      <td>最新公司股本结构</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>lb.secSusp</td>\n",
       "      <td>停复牌数据</td>\n",
       "      <td>停复牌</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       api      comment        name\n",
       "0          jy.balanceSheet        资产负债表       资产负债表\n",
       "1              jy.cashFlow        现金流量表       现金流量表\n",
       "2                jy.income          利润表         利润表\n",
       "3               jy.qincome        季度利润表       季度利润表\n",
       "4        jz.instrumentInfo       证券基本信息      证券基础信息\n",
       "5           jz.secTradeCal         交易日历        交易日历\n",
       "6          lb.balanceSheet        资产负债表       资产负债表\n",
       "7              lb.cashFlow        现金流量表       现金流量表\n",
       "8            lb.dcCoinInfo       数字货币信息      数字货币信息\n",
       "9               lb.dcDaily      数字货币日行情     数字货币日行情\n",
       "10       lb.dcExchangeInfo  十大数字货币交易所信息   数字货币交易所信息\n",
       "11          lb.dcTradeInfo   数字货币交易标的信息  数字货币交易标的信息\n",
       "12  lb.hkSecDailyIndicator      港股日行情指标     港股日行情指标\n",
       "13               lb.income          利润表         利润表\n",
       "14            lb.indexCons        指数成份股       指数成份股\n",
       "15            lb.indexInfo       指数基本信息      指数基本信息\n",
       "16         lb.industryType        行业代码表       行业代码表\n",
       "17       lb.mfDailyPerform     公募基金行情表现    公募基金行情表现\n",
       "18                lb.mfNav       公募基金净值      公募基金净值\n",
       "19         lb.secAdjFactor         复权因子        复权因子\n",
       "20          lb.secArchives         公司概况        公司概况\n",
       "21    lb.secDailyIndicator       股票每日指标      股票每日指标\n",
       "22      lb.secDailyPerform       股票行情表现      股票行情表现\n",
       "23          lb.secDividend         分红送股       分红送股表\n",
       "24     lb.secFinIndicators       财务数据指标      财务数据指标\n",
       "25     lb.secFrozenPledger    股东股权冻结和质押   股东股权冻结和质押\n",
       "26      lb.secHolderNumber         股东户数        股东户数\n",
       "27      lb.secHoldingStats       股东持股统计      股东持股统计\n",
       "28          lb.secIEXDaily      美股公司日行情     美股公司日行情\n",
       "29            lb.secIEXEps   美股公司每股收益指标  美股公司每股收益指标\n",
       "30       lb.secIEXFinIndex   美股公司财务报表指标  美股公司财务报表指标\n",
       "31         lb.secIEXSymbol     美股公司股票列表    美股公司股票列表\n",
       "32          lb.secIndustry       行业分类信息        行业分类\n",
       "33       lb.secMainHolders         股东名单        股东名单\n",
       "34    lb.secNewestFinIndex   A股公司最新财务指标  A股公司最新财务指标\n",
       "35   lb.secNewestShareStru     最新公司股本结构    最新公司股本结构\n",
       "36              lb.secSusp        停复牌数据         停复牌"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df , msg = api.query(\n",
    "                    view=\"help.apiList\",\n",
    "                    fields=\"\",\n",
    "                    filter=\"\")\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### help.apiParam\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 查询每个大类别下的可选字段及描述\n",
    "- 通过filter字段可以限定查询的大类\n",
    "- 返回结果中,param对应的即是dataview里的可选字段(fields)\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>api</th>\n",
       "      <th>comment</th>\n",
       "      <th>dtype</th>\n",
       "      <th>must</th>\n",
       "      <th>param</th>\n",
       "      <th>pname</th>\n",
       "      <th>ptype</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>jy.cashFlow</td>\n",
       "      <td></td>\n",
       "      <td>String</td>\n",
       "      <td>N</td>\n",
       "      <td>symbol</td>\n",
       "      <td>证券代码</td>\n",
       "      <td>IN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>jy.cashFlow</td>\n",
       "      <td></td>\n",
       "      <td>String</td>\n",
       "      <td>N</td>\n",
       "      <td>start_date</td>\n",
       "      <td>公告开始日期</td>\n",
       "      <td>IN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>jy.cashFlow</td>\n",
       "      <td></td>\n",
       "      <td>String</td>\n",
       "      <td>N</td>\n",
       "      <td>end_date</td>\n",
       "      <td>公告结束日期</td>\n",
       "      <td>IN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>jy.cashFlow</td>\n",
       "      <td></td>\n",
       "      <td>String</td>\n",
       "      <td>N</td>\n",
       "      <td>start_reportdate</td>\n",
       "      <td>报告期开始日期</td>\n",
       "      <td>IN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>jy.cashFlow</td>\n",
       "      <td></td>\n",
       "      <td>String</td>\n",
       "      <td>N</td>\n",
       "      <td>start_reportdate</td>\n",
       "      <td>报告期结束日期</td>\n",
       "      <td>IN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           api comment   dtype must             param    pname ptype\n",
       "0  jy.cashFlow          String    N            symbol     证券代码    IN\n",
       "1  jy.cashFlow          String    N        start_date   公告开始日期    IN\n",
       "2  jy.cashFlow          String    N          end_date   公告结束日期    IN\n",
       "3  jy.cashFlow          String    N  start_reportdate  报告期开始日期    IN\n",
       "4  jy.cashFlow          String    N  start_reportdate  报告期结束日期    IN"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df ,msg = api.query(view=\"help.apiParam\",fields=\"\",filter=\"api=jy.cashFlow\") # 查询现金流量表可选字段\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据查询"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### fields\n",
    "- ` jaqs_fxdayu.data.Dataview.fields `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 当前dataview中的数据字段\n",
    "- 说明：\n",
    "  -  初始请求数据时指定universe，会自动补充index_member(是否是指数成分股)、index_weight(指数成分权重)字段；若universe为多标,取设置的第一个指数为准补充index_member和index_weight\n",
    "  -  初始请求数据时指定all_price=True,会请求open、high、low、close、vwap及相应复权后的结果open_adj、high_adj、low_adj、close_adj、vwap_adj\n",
    "  -  请求行情类数据（open、high、low、close、vwap）,若adjust_mode不为空（默认为\"post\"）,会补充相应复权后结果并以'_adj'为后缀。\n",
    "  -  初始请求数据字段中包含季度数据,会自动按时间、标的整理对齐一份到日级别上\n",
    "  -  初始请求数据默认会自动补充adjust_factor(复权因子)、trade_status(交易状态-停牌or可交易)、ann_date(财报公告时间-季度数据)、quarter(季度数据对应披露月份)\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['pe',\n",
       " 'oper_exp',\n",
       " 'high_adj',\n",
       " 'index_weight',\n",
       " 'quarter',\n",
       " 'trade_status',\n",
       " 'low',\n",
       " 'close_adj',\n",
       " 'ann_date',\n",
       " 'open',\n",
       " 'sw1',\n",
       " 'close',\n",
       " 'high',\n",
       " 'low_adj',\n",
       " 'vwap_adj',\n",
       " 'adjust_factor',\n",
       " 'open_adj',\n",
       " 'vwap',\n",
       " 'total_oper_rev',\n",
       " 'index_member',\n",
       " 'pb']"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.fields"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### _get_fields\n",
    "- ` jaqs_fxdayu.data.Dataview._get_fields(field_type, fields) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 查询众多字段属于某种类型的数据\n",
    "  - field_type:{'market_daily', 'ref_daily', 'income', 'balance_sheet', 'cash_flow', 'fin_indicator', 'group', 'daily', 'quarterly'\n",
    "   (对应类型分别为 日行情、日参考数据、收入相关、balance_sheet相关、现金流相关、财务指标相关、行业分类相关、日级别数据、季度级别数据)\n",
    "  - fields:list of str\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['ann_date', 'quarter', 'oper_exp', 'total_oper_rev']"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv._get_fields('quarterly',dv.fields) # 查询数据集的字段里有哪些是季度级别数据"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  symbol\n",
    "- ` jaqs_fxdayu.data.Dataview.symbol `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 当前dataview中的标的品种\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['000001.SZ', '000002.SZ']"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.symbol[:2] # 前两只股票"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### universe\n",
    "- ` jaqs_fxdayu.data.Dataview.universe `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 当前dataview中股票池的指数代码\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['000300.SH']"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.universe"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### benchmark\n",
    "- ` jaqs_fxdayu.data.Dataview.benchmark `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 当前dataview中的基准代码\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'000300.SH'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.benchmark"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### data_benchmark\n",
    "- ` jaqs_fxdayu.data.Dataview.data_benchmark `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 当前dataview中的基准的日行情数据\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>close</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170306</th>\n",
       "      <td>3446.4840</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170307</th>\n",
       "      <td>3453.9565</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170308</th>\n",
       "      <td>3448.7313</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170309</th>\n",
       "      <td>3426.9438</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170310</th>\n",
       "      <td>3427.8916</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                close\n",
       "trade_date           \n",
       "20170306    3446.4840\n",
       "20170307    3453.9565\n",
       "20170308    3448.7313\n",
       "20170309    3426.9438\n",
       "20170310    3427.8916"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.data_benchmark.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### data_inst\n",
    "- ` jaqs_fxdayu.data.Dataview.data_inst `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 数据集中的证券基础信息\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>buylot</th>\n",
       "      <th>delist_date</th>\n",
       "      <th>inst_type</th>\n",
       "      <th>list_date</th>\n",
       "      <th>multiplier</th>\n",
       "      <th>name</th>\n",
       "      <th>pricetick</th>\n",
       "      <th>product</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>symbol</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>600000.SH</th>\n",
       "      <td>100</td>\n",
       "      <td>99999999</td>\n",
       "      <td>1</td>\n",
       "      <td>19991110</td>\n",
       "      <td>1</td>\n",
       "      <td>浦发银行</td>\n",
       "      <td>0.01</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>600016.SH</th>\n",
       "      <td>100</td>\n",
       "      <td>99999999</td>\n",
       "      <td>1</td>\n",
       "      <td>20001219</td>\n",
       "      <td>1</td>\n",
       "      <td>民生银行</td>\n",
       "      <td>0.01</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>600030.SH</th>\n",
       "      <td>100</td>\n",
       "      <td>99999999</td>\n",
       "      <td>1</td>\n",
       "      <td>20030106</td>\n",
       "      <td>1</td>\n",
       "      <td>中信证券</td>\n",
       "      <td>0.01</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>600050.SH</th>\n",
       "      <td>100</td>\n",
       "      <td>99999999</td>\n",
       "      <td>1</td>\n",
       "      <td>20021009</td>\n",
       "      <td>1</td>\n",
       "      <td>中国联通</td>\n",
       "      <td>0.01</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>600109.SH</th>\n",
       "      <td>100</td>\n",
       "      <td>99999999</td>\n",
       "      <td>1</td>\n",
       "      <td>19970807</td>\n",
       "      <td>1</td>\n",
       "      <td>国金证券</td>\n",
       "      <td>0.01</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           buylot  delist_date  inst_type  list_date  multiplier  name  \\\n",
       "symbol                                                                   \n",
       "600000.SH     100     99999999          1   19991110           1  浦发银行   \n",
       "600016.SH     100     99999999          1   20001219           1  民生银行   \n",
       "600030.SH     100     99999999          1   20030106           1  中信证券   \n",
       "600050.SH     100     99999999          1   20021009           1  中国联通   \n",
       "600109.SH     100     99999999          1   19970807           1  国金证券   \n",
       "\n",
       "           pricetick product  \n",
       "symbol                        \n",
       "600000.SH       0.01          \n",
       "600016.SH       0.01          \n",
       "600030.SH       0.01          \n",
       "600050.SH       0.01          \n",
       "600109.SH       0.01          "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.data_inst.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "|字段|字段中文名|\n",
    "|:----    |:---|\n",
    "|inst_type|\t证券类型|\n",
    "|symbol\t|证券代码|\n",
    "|name\t|证券名称|\n",
    "|list_date\t|上市日期|\n",
    "|delist_date|\t退市日期|\n",
    "|buylot\t|最小买入单位|\n",
    "|pricetick\t|最小变动单位|\n",
    "|product\t|合约品种|\n",
    "|multiplier\t|合约乘数|"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### dates\n",
    "- ` jaqs_fxdayu.data.Dataview.dates `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 数据的日期序列\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([20170306, 20170307])"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.dates[:2] #日期序列前两个"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### data_d\n",
    "- ` jaqs_fxdayu.data.Dataview.data_d`\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 日级别数据集\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th>symbol</th>\n",
       "      <th colspan=\"10\" halign=\"left\">000001.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th colspan=\"10\" halign=\"left\">603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>field</th>\n",
       "      <th>adjust_factor</th>\n",
       "      <th>ann_date</th>\n",
       "      <th>close</th>\n",
       "      <th>close_adj</th>\n",
       "      <th>high</th>\n",
       "      <th>high_adj</th>\n",
       "      <th>index_member</th>\n",
       "      <th>index_weight</th>\n",
       "      <th>low</th>\n",
       "      <th>low_adj</th>\n",
       "      <th>...</th>\n",
       "      <th>open_adj</th>\n",
       "      <th>oper_exp</th>\n",
       "      <th>pb</th>\n",
       "      <th>pe</th>\n",
       "      <th>quarter</th>\n",
       "      <th>sw1</th>\n",
       "      <th>total_oper_rev</th>\n",
       "      <th>trade_status</th>\n",
       "      <th>vwap</th>\n",
       "      <th>vwap_adj</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170306</th>\n",
       "      <td>100.523</td>\n",
       "      <td>20161021.0</td>\n",
       "      <td>9.45</td>\n",
       "      <td>949.94235</td>\n",
       "      <td>9.46</td>\n",
       "      <td>950.94758</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.008449</td>\n",
       "      <td>9.39</td>\n",
       "      <td>943.91097</td>\n",
       "      <td>...</td>\n",
       "      <td>15.685408</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.7252</td>\n",
       "      <td>110.7088</td>\n",
       "      <td>9.0</td>\n",
       "      <td>240000</td>\n",
       "      <td>3.496036e+09</td>\n",
       "      <td>交易</td>\n",
       "      <td>4.97</td>\n",
       "      <td>15.94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170307</th>\n",
       "      <td>100.523</td>\n",
       "      <td>20161021.0</td>\n",
       "      <td>9.45</td>\n",
       "      <td>949.94235</td>\n",
       "      <td>9.46</td>\n",
       "      <td>950.94758</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.008449</td>\n",
       "      <td>9.40</td>\n",
       "      <td>944.91620</td>\n",
       "      <td>...</td>\n",
       "      <td>15.974097</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.5926</td>\n",
       "      <td>107.6027</td>\n",
       "      <td>9.0</td>\n",
       "      <td>240000</td>\n",
       "      <td>3.496036e+09</td>\n",
       "      <td>交易</td>\n",
       "      <td>4.88</td>\n",
       "      <td>15.66</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170308</th>\n",
       "      <td>100.523</td>\n",
       "      <td>20161021.0</td>\n",
       "      <td>9.42</td>\n",
       "      <td>946.92666</td>\n",
       "      <td>9.45</td>\n",
       "      <td>949.94235</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.008449</td>\n",
       "      <td>9.40</td>\n",
       "      <td>944.91620</td>\n",
       "      <td>...</td>\n",
       "      <td>15.557102</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.6211</td>\n",
       "      <td>108.2683</td>\n",
       "      <td>9.0</td>\n",
       "      <td>240000</td>\n",
       "      <td>3.496036e+09</td>\n",
       "      <td>交易</td>\n",
       "      <td>4.87</td>\n",
       "      <td>15.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170309</th>\n",
       "      <td>100.523</td>\n",
       "      <td>20161021.0</td>\n",
       "      <td>9.38</td>\n",
       "      <td>942.90574</td>\n",
       "      <td>9.43</td>\n",
       "      <td>947.93189</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.008449</td>\n",
       "      <td>9.36</td>\n",
       "      <td>940.89528</td>\n",
       "      <td>...</td>\n",
       "      <td>15.781638</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.6495</td>\n",
       "      <td>108.9339</td>\n",
       "      <td>9.0</td>\n",
       "      <td>240000</td>\n",
       "      <td>3.496036e+09</td>\n",
       "      <td>交易</td>\n",
       "      <td>4.95</td>\n",
       "      <td>15.89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170310</th>\n",
       "      <td>100.523</td>\n",
       "      <td>20161021.0</td>\n",
       "      <td>9.40</td>\n",
       "      <td>944.91620</td>\n",
       "      <td>9.41</td>\n",
       "      <td>945.92143</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.008449</td>\n",
       "      <td>9.36</td>\n",
       "      <td>940.89528</td>\n",
       "      <td>...</td>\n",
       "      <td>15.525026</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.6021</td>\n",
       "      <td>107.8246</td>\n",
       "      <td>9.0</td>\n",
       "      <td>240000</td>\n",
       "      <td>3.496036e+09</td>\n",
       "      <td>交易</td>\n",
       "      <td>4.87</td>\n",
       "      <td>15.62</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 6930 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol         000001.SZ                                                \\\n",
       "field      adjust_factor    ann_date close  close_adj  high   high_adj   \n",
       "trade_date                                                               \n",
       "20170306         100.523  20161021.0  9.45  949.94235  9.46  950.94758   \n",
       "20170307         100.523  20161021.0  9.45  949.94235  9.46  950.94758   \n",
       "20170308         100.523  20161021.0  9.42  946.92666  9.45  949.94235   \n",
       "20170309         100.523  20161021.0  9.38  942.90574  9.43  947.93189   \n",
       "20170310         100.523  20161021.0  9.40  944.91620  9.41  945.92143   \n",
       "\n",
       "symbol                                                  ...     603993.SH  \\\n",
       "field      index_member index_weight   low    low_adj   ...      open_adj   \n",
       "trade_date                                              ...                 \n",
       "20170306            1.0     0.008449  9.39  943.91097   ...     15.685408   \n",
       "20170307            1.0     0.008449  9.40  944.91620   ...     15.974097   \n",
       "20170308            1.0     0.008449  9.40  944.91620   ...     15.557102   \n",
       "20170309            1.0     0.008449  9.36  940.89528   ...     15.781638   \n",
       "20170310            1.0     0.008449  9.36  940.89528   ...     15.525026   \n",
       "\n",
       "symbol                                                                \\\n",
       "field      oper_exp      pb        pe quarter     sw1 total_oper_rev   \n",
       "trade_date                                                             \n",
       "20170306        0.0  4.7252  110.7088     9.0  240000   3.496036e+09   \n",
       "20170307        0.0  4.5926  107.6027     9.0  240000   3.496036e+09   \n",
       "20170308        0.0  4.6211  108.2683     9.0  240000   3.496036e+09   \n",
       "20170309        0.0  4.6495  108.9339     9.0  240000   3.496036e+09   \n",
       "20170310        0.0  4.6021  107.8246     9.0  240000   3.496036e+09   \n",
       "\n",
       "symbol                                  \n",
       "field      trade_status  vwap vwap_adj  \n",
       "trade_date                              \n",
       "20170306             交易  4.97    15.94  \n",
       "20170307             交易  4.88    15.66  \n",
       "20170308             交易  4.87    15.62  \n",
       "20170309             交易  4.95    15.89  \n",
       "20170310             交易  4.87    15.62  \n",
       "\n",
       "[5 rows x 6930 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.data_d.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  data_q\n",
    "- ` jaqs_fxdayu.data.Dataview.data_q `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 季度级别数据集\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th>symbol</th>\n",
       "      <th colspan=\"4\" halign=\"left\">000001.SZ</th>\n",
       "      <th colspan=\"4\" halign=\"left\">000002.SZ</th>\n",
       "      <th colspan=\"2\" halign=\"left\">000008.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th colspan=\"2\" halign=\"left\">603858.SH</th>\n",
       "      <th colspan=\"4\" halign=\"left\">603885.SH</th>\n",
       "      <th colspan=\"4\" halign=\"left\">603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>field</th>\n",
       "      <th>ann_date</th>\n",
       "      <th>oper_exp</th>\n",
       "      <th>quarter</th>\n",
       "      <th>total_oper_rev</th>\n",
       "      <th>ann_date</th>\n",
       "      <th>oper_exp</th>\n",
       "      <th>quarter</th>\n",
       "      <th>total_oper_rev</th>\n",
       "      <th>ann_date</th>\n",
       "      <th>oper_exp</th>\n",
       "      <th>...</th>\n",
       "      <th>quarter</th>\n",
       "      <th>total_oper_rev</th>\n",
       "      <th>ann_date</th>\n",
       "      <th>oper_exp</th>\n",
       "      <th>quarter</th>\n",
       "      <th>total_oper_rev</th>\n",
       "      <th>ann_date</th>\n",
       "      <th>oper_exp</th>\n",
       "      <th>quarter</th>\n",
       "      <th>total_oper_rev</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20140930</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>9</td>\n",
       "      <td>NaN</td>\n",
       "      <td>20151031.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9</td>\n",
       "      <td>5.092343e+09</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20150331</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>20160421.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3</td>\n",
       "      <td>1.956667e+09</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20150630</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20150930</th>\n",
       "      <td>20151023.0</td>\n",
       "      <td>4.784700e+10</td>\n",
       "      <td>9</td>\n",
       "      <td>7.115200e+10</td>\n",
       "      <td>20151028.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9</td>\n",
       "      <td>7.959621e+10</td>\n",
       "      <td>20151031.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>9</td>\n",
       "      <td>7.774995e+09</td>\n",
       "      <td>20151031.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9</td>\n",
       "      <td>6.262755e+09</td>\n",
       "      <td>20151030.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9</td>\n",
       "      <td>3.174664e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20151231</th>\n",
       "      <td>20160310.0</td>\n",
       "      <td>6.726800e+10</td>\n",
       "      <td>12</td>\n",
       "      <td>9.616300e+10</td>\n",
       "      <td>20160314.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>12</td>\n",
       "      <td>1.955491e+11</td>\n",
       "      <td>20160427.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>12</td>\n",
       "      <td>1.165563e+10</td>\n",
       "      <td>20160415.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>12</td>\n",
       "      <td>8.158238e+09</td>\n",
       "      <td>20160325.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>12</td>\n",
       "      <td>4.196840e+09</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 1320 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol       000001.SZ                                        000002.SZ  \\\n",
       "field         ann_date      oper_exp quarter total_oper_rev    ann_date   \n",
       "trade_date                                                                \n",
       "20140930           NaN           NaN       9            NaN         NaN   \n",
       "20150331           NaN           NaN       3            NaN         NaN   \n",
       "20150630           NaN           NaN       6            NaN         NaN   \n",
       "20150930    20151023.0  4.784700e+10       9   7.115200e+10  20151028.0   \n",
       "20151231    20160310.0  6.726800e+10      12   9.616300e+10  20160314.0   \n",
       "\n",
       "symbol                                       000008.SZ           \\\n",
       "field      oper_exp quarter total_oper_rev    ann_date oper_exp   \n",
       "trade_date                                                        \n",
       "20140930        NaN       9            NaN         NaN      NaN   \n",
       "20150331        NaN       3            NaN         NaN      NaN   \n",
       "20150630        NaN       6            NaN         NaN      NaN   \n",
       "20150930        0.0       9   7.959621e+10  20151031.0      0.0   \n",
       "20151231        0.0      12   1.955491e+11  20160427.0      0.0   \n",
       "\n",
       "symbol          ...       603858.SH                  603885.SH           \\\n",
       "field           ...         quarter total_oper_rev    ann_date oper_exp   \n",
       "trade_date      ...                                                       \n",
       "20140930        ...               9            NaN  20151031.0      0.0   \n",
       "20150331        ...               3            NaN  20160421.0      0.0   \n",
       "20150630        ...               6            NaN         NaN      NaN   \n",
       "20150930        ...               9   7.774995e+09  20151031.0      0.0   \n",
       "20151231        ...              12   1.165563e+10  20160415.0      0.0   \n",
       "\n",
       "symbol                              603993.SH                                  \n",
       "field      quarter total_oper_rev    ann_date oper_exp quarter total_oper_rev  \n",
       "trade_date                                                                     \n",
       "20140930         9   5.092343e+09         NaN      NaN       9            NaN  \n",
       "20150331         3   1.956667e+09         NaN      NaN       3            NaN  \n",
       "20150630         6            NaN         NaN      NaN       6            NaN  \n",
       "20150930         9   6.262755e+09  20151030.0      0.0       9   3.174664e+09  \n",
       "20151231        12   8.158238e+09  20160325.0      0.0      12   4.196840e+09  \n",
       "\n",
       "[5 rows x 1320 columns]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.data_q.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### get\n",
    "- ` jaqs_fxdayu.data.Dataview.get(symbol=\"\", start_date=0, end_date=0, fields=\"\", date_type=\"int\") `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 综合查询方法：按品种+字段+日期查询数据，返回日期为索引，品种+字段(MultiIndex)为columns的DataFrame\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|symbol|否 |string|标的代码，多标的以','隔开，如'000001.SH,600300.SH',默认查询数据集中所有标的|\n",
    "|start_date |否 |int |开始日期，默认从数据集开始日期起|\n",
    "|end_date |否 |int |结束日期，默认到数据集结束日期|\n",
    "|fields |否 |string |数据字段，多字段以','隔开，如'open,close,high,low'，默认查询数据集中所有字段|\n",
    "|date_type |否 |\"int\"/\"datetime\" |日期作为索引时返回的索引类型，默认为\"int\",即日期为整型;当设置为\"datetime\"时，日期索引返回为python datetime格式|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th>symbol</th>\n",
       "      <th colspan=\"2\" halign=\"left\">000001.SZ</th>\n",
       "      <th colspan=\"2\" halign=\"left\">000002.SZ</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>field</th>\n",
       "      <th>high</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>open</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170502</th>\n",
       "      <td>8.96</td>\n",
       "      <td>8.96</td>\n",
       "      <td>19.37</td>\n",
       "      <td>19.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170503</th>\n",
       "      <td>8.93</td>\n",
       "      <td>8.92</td>\n",
       "      <td>19.25</td>\n",
       "      <td>19.20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170504</th>\n",
       "      <td>8.89</td>\n",
       "      <td>8.89</td>\n",
       "      <td>19.19</td>\n",
       "      <td>18.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170505</th>\n",
       "      <td>8.76</td>\n",
       "      <td>8.74</td>\n",
       "      <td>19.07</td>\n",
       "      <td>18.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170508</th>\n",
       "      <td>8.62</td>\n",
       "      <td>8.60</td>\n",
       "      <td>18.96</td>\n",
       "      <td>18.89</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol     000001.SZ       000002.SZ       \n",
       "field           high  open      high   open\n",
       "trade_date                                 \n",
       "20170502        8.96  8.96     19.37  19.30\n",
       "20170503        8.93  8.92     19.25  19.20\n",
       "20170504        8.89  8.89     19.19  18.90\n",
       "20170505        8.76  8.74     19.07  18.95\n",
       "20170508        8.62  8.60     18.96  18.89"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.get(\"000001.SZ,000002.SZ\",fields=\"open,high\").head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### get_snapshot\n",
    "- ` jaqs_fxdayu.data.Dataview.get_snapshot(snapshot_date, symbol=\"\", fields=\"\") `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 切片查询方法：指定日期，按品种+字段查询数据，返回品种为索引，字段为columns的DataFrame\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|snapshot_date |是 |int |指定查询切片的日期|\n",
    "|symbol|否 |string|标的代码，多标的以','隔开，如'000001.SH,600300.SH',默认查询数据集中所有标的|\n",
    "|fields |否 |string |数据字段，多字段以','隔开，如'open,close,high,low'，默认查询数据集中所有字段|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>field</th>\n",
       "      <th>high</th>\n",
       "      <th>open</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>symbol</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>000001.SZ</th>\n",
       "      <td>8.89</td>\n",
       "      <td>8.89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>000002.SZ</th>\n",
       "      <td>19.19</td>\n",
       "      <td>18.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>000008.SZ</th>\n",
       "      <td>7.93</td>\n",
       "      <td>7.93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>000009.SZ</th>\n",
       "      <td>8.65</td>\n",
       "      <td>8.51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>000027.SZ</th>\n",
       "      <td>6.93</td>\n",
       "      <td>6.84</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "field       high   open\n",
       "symbol                 \n",
       "000001.SZ   8.89   8.89\n",
       "000002.SZ  19.19  18.90\n",
       "000008.SZ   7.93   7.93\n",
       "000009.SZ   8.65   8.51\n",
       "000027.SZ   6.93   6.84"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.get_snapshot(20170504, fields=\"open,high\").head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### get_symbol\n",
    "- ` jaqs_fxdayu.data.Dataview.get_symbol(symbol, start_date=0, end_date=0, fields=\"\", date_type=\"int\") `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 切片查询方法：指定品种，按时间+字段查询数据，返回时间为索引，字段为columns的DataFrame\n",
    "- 查询的结果为日频（季度数据也会被自动扩展为日频）\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|symbol|是 |string|标的代码，**单标的**|\n",
    "|start_date |否 |int |开始日期，默认从数据集开始日期起|\n",
    "|end_date |否 |int |结束日期，默认到数据集结束日期|\n",
    "|fields |否 |string |字段名称，多字段以\",\"隔开,如\"close,open\"，默认查询数据集所有的字段|\n",
    "|date_type |否 |\"int\"/\"datetime\" |日期作为索引时返回的索引类型，默认为\"int\",即日期为整型;当设置为\"datetime\"时，日期索引返回为python datetime格式|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>field</th>\n",
       "      <th>adjust_factor</th>\n",
       "      <th>ann_date</th>\n",
       "      <th>close</th>\n",
       "      <th>close_adj</th>\n",
       "      <th>high</th>\n",
       "      <th>high_adj</th>\n",
       "      <th>index_member</th>\n",
       "      <th>index_weight</th>\n",
       "      <th>low</th>\n",
       "      <th>low_adj</th>\n",
       "      <th>...</th>\n",
       "      <th>open_adj</th>\n",
       "      <th>oper_exp</th>\n",
       "      <th>pb</th>\n",
       "      <th>pe</th>\n",
       "      <th>quarter</th>\n",
       "      <th>sw1</th>\n",
       "      <th>total_oper_rev</th>\n",
       "      <th>trade_status</th>\n",
       "      <th>vwap</th>\n",
       "      <th>vwap_adj</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170502</th>\n",
       "      <td>100.523</td>\n",
       "      <td>20170422.0</td>\n",
       "      <td>8.94</td>\n",
       "      <td>898.67562</td>\n",
       "      <td>8.96</td>\n",
       "      <td>900.68608</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.008049</td>\n",
       "      <td>8.90</td>\n",
       "      <td>894.65470</td>\n",
       "      <td>...</td>\n",
       "      <td>900.68608</td>\n",
       "      <td>1.951800e+10</td>\n",
       "      <td>0.8174</td>\n",
       "      <td>6.7925</td>\n",
       "      <td>3.0</td>\n",
       "      <td>银行</td>\n",
       "      <td>2.753200e+10</td>\n",
       "      <td>1.0</td>\n",
       "      <td>8.93</td>\n",
       "      <td>897.41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170503</th>\n",
       "      <td>100.523</td>\n",
       "      <td>20170422.0</td>\n",
       "      <td>8.91</td>\n",
       "      <td>895.65993</td>\n",
       "      <td>8.93</td>\n",
       "      <td>897.67039</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.008049</td>\n",
       "      <td>8.89</td>\n",
       "      <td>893.64947</td>\n",
       "      <td>...</td>\n",
       "      <td>896.66516</td>\n",
       "      <td>1.951800e+10</td>\n",
       "      <td>0.8147</td>\n",
       "      <td>6.7697</td>\n",
       "      <td>3.0</td>\n",
       "      <td>银行</td>\n",
       "      <td>2.753200e+10</td>\n",
       "      <td>1.0</td>\n",
       "      <td>8.91</td>\n",
       "      <td>895.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170504</th>\n",
       "      <td>100.523</td>\n",
       "      <td>20170422.0</td>\n",
       "      <td>8.74</td>\n",
       "      <td>878.57102</td>\n",
       "      <td>8.89</td>\n",
       "      <td>893.64947</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.008049</td>\n",
       "      <td>8.72</td>\n",
       "      <td>876.56056</td>\n",
       "      <td>...</td>\n",
       "      <td>893.64947</td>\n",
       "      <td>1.951800e+10</td>\n",
       "      <td>0.7992</td>\n",
       "      <td>6.6405</td>\n",
       "      <td>3.0</td>\n",
       "      <td>银行</td>\n",
       "      <td>2.753200e+10</td>\n",
       "      <td>1.0</td>\n",
       "      <td>8.81</td>\n",
       "      <td>885.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170505</th>\n",
       "      <td>100.523</td>\n",
       "      <td>20170422.0</td>\n",
       "      <td>8.63</td>\n",
       "      <td>867.51349</td>\n",
       "      <td>8.76</td>\n",
       "      <td>880.58148</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.008049</td>\n",
       "      <td>8.58</td>\n",
       "      <td>862.48734</td>\n",
       "      <td>...</td>\n",
       "      <td>878.57102</td>\n",
       "      <td>1.951800e+10</td>\n",
       "      <td>0.7891</td>\n",
       "      <td>6.5570</td>\n",
       "      <td>3.0</td>\n",
       "      <td>银行</td>\n",
       "      <td>2.753200e+10</td>\n",
       "      <td>1.0</td>\n",
       "      <td>8.65</td>\n",
       "      <td>869.59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170508</th>\n",
       "      <td>100.523</td>\n",
       "      <td>20170422.0</td>\n",
       "      <td>8.57</td>\n",
       "      <td>861.48211</td>\n",
       "      <td>8.62</td>\n",
       "      <td>866.50826</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.008049</td>\n",
       "      <td>8.54</td>\n",
       "      <td>858.46642</td>\n",
       "      <td>...</td>\n",
       "      <td>864.49780</td>\n",
       "      <td>1.951800e+10</td>\n",
       "      <td>0.7836</td>\n",
       "      <td>6.5114</td>\n",
       "      <td>3.0</td>\n",
       "      <td>银行</td>\n",
       "      <td>2.753200e+10</td>\n",
       "      <td>1.0</td>\n",
       "      <td>8.57</td>\n",
       "      <td>861.76</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "field       adjust_factor    ann_date  close  close_adj  high   high_adj  \\\n",
       "trade_date                                                                 \n",
       "20170502          100.523  20170422.0   8.94  898.67562  8.96  900.68608   \n",
       "20170503          100.523  20170422.0   8.91  895.65993  8.93  897.67039   \n",
       "20170504          100.523  20170422.0   8.74  878.57102  8.89  893.64947   \n",
       "20170505          100.523  20170422.0   8.63  867.51349  8.76  880.58148   \n",
       "20170508          100.523  20170422.0   8.57  861.48211  8.62  866.50826   \n",
       "\n",
       "field       index_member  index_weight   low    low_adj    ...      open_adj  \\\n",
       "trade_date                                                 ...                 \n",
       "20170502             1.0      0.008049  8.90  894.65470    ...     900.68608   \n",
       "20170503             1.0      0.008049  8.89  893.64947    ...     896.66516   \n",
       "20170504             1.0      0.008049  8.72  876.56056    ...     893.64947   \n",
       "20170505             1.0      0.008049  8.58  862.48734    ...     878.57102   \n",
       "20170508             1.0      0.008049  8.54  858.46642    ...     864.49780   \n",
       "\n",
       "field           oper_exp      pb      pe  quarter  sw1 total_oper_rev  \\\n",
       "trade_date                                                              \n",
       "20170502    1.951800e+10  0.8174  6.7925      3.0   银行   2.753200e+10   \n",
       "20170503    1.951800e+10  0.8147  6.7697      3.0   银行   2.753200e+10   \n",
       "20170504    1.951800e+10  0.7992  6.6405      3.0   银行   2.753200e+10   \n",
       "20170505    1.951800e+10  0.7891  6.5570      3.0   银行   2.753200e+10   \n",
       "20170508    1.951800e+10  0.7836  6.5114      3.0   银行   2.753200e+10   \n",
       "\n",
       "field       trade_status  vwap  vwap_adj  \n",
       "trade_date                                \n",
       "20170502             1.0  8.93    897.41  \n",
       "20170503             1.0  8.91    895.32  \n",
       "20170504             1.0  8.81    885.83  \n",
       "20170505             1.0  8.65    869.59  \n",
       "20170508             1.0  8.57    861.76  \n",
       "\n",
       "[5 rows x 21 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.get_symbol(\"000001.SZ\").head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### get_ts\n",
    "- ` jaqs_fxdayu.data.Dataview.get_ts(field, symbol=\"\", start_date=0, end_date=0, date_type=\"int\") `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 切片查询方法：指定字段，按时间+品种查询数据，返回时间为索引，品种为columns的DataFrame\n",
    "- 查询的结果为日频（季度数据也会被自动扩展为日频）\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|symbol|否 |string|标的代码，多标的以','隔开，如'000001.SH,600300.SH',默认查询数据集中所有标的|\n",
    "|start_date |否 |int |开始日期，默认从数据集开始日期起|\n",
    "|end_date |否 |int |结束日期，默认到数据集结束日期|\n",
    "|field |是 |string |数据字段,**单字段**|\n",
    "|date_type |否 |\"int\"/\"datetime\" |日期作为索引时返回的索引类型，默认为\"int\",即日期为整型;当设置为\"datetime\"时，日期索引返回为python datetime格式|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>symbol</th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601992.SH</th>\n",
       "      <th>601997.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603160.SH</th>\n",
       "      <th>603858.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170502</th>\n",
       "      <td>8.96</td>\n",
       "      <td>19.30</td>\n",
       "      <td>8.09</td>\n",
       "      <td>8.40</td>\n",
       "      <td>6.99</td>\n",
       "      <td>16.09</td>\n",
       "      <td>10.33</td>\n",
       "      <td>9.32</td>\n",
       "      <td>17.73</td>\n",
       "      <td>8.15</td>\n",
       "      <td>...</td>\n",
       "      <td>3.58</td>\n",
       "      <td>7.05</td>\n",
       "      <td>8.09</td>\n",
       "      <td>15.70</td>\n",
       "      <td>6.01</td>\n",
       "      <td>14.90</td>\n",
       "      <td>96.55</td>\n",
       "      <td>80.25</td>\n",
       "      <td>22.28</td>\n",
       "      <td>4.41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170503</th>\n",
       "      <td>8.92</td>\n",
       "      <td>19.20</td>\n",
       "      <td>7.99</td>\n",
       "      <td>8.52</td>\n",
       "      <td>6.95</td>\n",
       "      <td>16.06</td>\n",
       "      <td>10.24</td>\n",
       "      <td>9.32</td>\n",
       "      <td>17.58</td>\n",
       "      <td>8.09</td>\n",
       "      <td>...</td>\n",
       "      <td>3.55</td>\n",
       "      <td>6.96</td>\n",
       "      <td>8.15</td>\n",
       "      <td>15.67</td>\n",
       "      <td>5.97</td>\n",
       "      <td>14.90</td>\n",
       "      <td>97.88</td>\n",
       "      <td>80.60</td>\n",
       "      <td>22.28</td>\n",
       "      <td>4.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170504</th>\n",
       "      <td>8.89</td>\n",
       "      <td>18.90</td>\n",
       "      <td>7.93</td>\n",
       "      <td>8.51</td>\n",
       "      <td>6.84</td>\n",
       "      <td>15.96</td>\n",
       "      <td>10.13</td>\n",
       "      <td>9.22</td>\n",
       "      <td>17.78</td>\n",
       "      <td>7.96</td>\n",
       "      <td>...</td>\n",
       "      <td>3.53</td>\n",
       "      <td>6.85</td>\n",
       "      <td>7.58</td>\n",
       "      <td>15.68</td>\n",
       "      <td>5.90</td>\n",
       "      <td>14.80</td>\n",
       "      <td>97.20</td>\n",
       "      <td>80.50</td>\n",
       "      <td>22.40</td>\n",
       "      <td>4.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170505</th>\n",
       "      <td>8.74</td>\n",
       "      <td>18.95</td>\n",
       "      <td>7.90</td>\n",
       "      <td>8.54</td>\n",
       "      <td>6.85</td>\n",
       "      <td>15.70</td>\n",
       "      <td>9.91</td>\n",
       "      <td>9.16</td>\n",
       "      <td>17.80</td>\n",
       "      <td>7.98</td>\n",
       "      <td>...</td>\n",
       "      <td>3.52</td>\n",
       "      <td>6.74</td>\n",
       "      <td>7.78</td>\n",
       "      <td>15.56</td>\n",
       "      <td>5.85</td>\n",
       "      <td>14.35</td>\n",
       "      <td>97.00</td>\n",
       "      <td>79.71</td>\n",
       "      <td>22.40</td>\n",
       "      <td>4.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170508</th>\n",
       "      <td>8.60</td>\n",
       "      <td>18.89</td>\n",
       "      <td>7.52</td>\n",
       "      <td>8.26</td>\n",
       "      <td>6.79</td>\n",
       "      <td>15.17</td>\n",
       "      <td>9.89</td>\n",
       "      <td>9.10</td>\n",
       "      <td>17.56</td>\n",
       "      <td>7.87</td>\n",
       "      <td>...</td>\n",
       "      <td>3.52</td>\n",
       "      <td>6.59</td>\n",
       "      <td>7.80</td>\n",
       "      <td>15.05</td>\n",
       "      <td>5.83</td>\n",
       "      <td>14.11</td>\n",
       "      <td>94.11</td>\n",
       "      <td>78.31</td>\n",
       "      <td>22.32</td>\n",
       "      <td>4.23</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 330 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol      000001.SZ  000002.SZ  000008.SZ  000009.SZ  000027.SZ  000039.SZ  \\\n",
       "trade_date                                                                     \n",
       "20170502         8.96      19.30       8.09       8.40       6.99      16.09   \n",
       "20170503         8.92      19.20       7.99       8.52       6.95      16.06   \n",
       "20170504         8.89      18.90       7.93       8.51       6.84      15.96   \n",
       "20170505         8.74      18.95       7.90       8.54       6.85      15.70   \n",
       "20170508         8.60      18.89       7.52       8.26       6.79      15.17   \n",
       "\n",
       "symbol      000060.SZ  000061.SZ  000063.SZ  000069.SZ    ...      601988.SH  \\\n",
       "trade_date                                                ...                  \n",
       "20170502        10.33       9.32      17.73       8.15    ...           3.58   \n",
       "20170503        10.24       9.32      17.58       8.09    ...           3.55   \n",
       "20170504        10.13       9.22      17.78       7.96    ...           3.53   \n",
       "20170505         9.91       9.16      17.80       7.98    ...           3.52   \n",
       "20170508         9.89       9.10      17.56       7.87    ...           3.52   \n",
       "\n",
       "symbol      601989.SH  601992.SH  601997.SH  601998.SH  603000.SH  603160.SH  \\\n",
       "trade_date                                                                     \n",
       "20170502         7.05       8.09      15.70       6.01      14.90      96.55   \n",
       "20170503         6.96       8.15      15.67       5.97      14.90      97.88   \n",
       "20170504         6.85       7.58      15.68       5.90      14.80      97.20   \n",
       "20170505         6.74       7.78      15.56       5.85      14.35      97.00   \n",
       "20170508         6.59       7.80      15.05       5.83      14.11      94.11   \n",
       "\n",
       "symbol      603858.SH  603885.SH  603993.SH  \n",
       "trade_date                                   \n",
       "20170502        80.25      22.28       4.41  \n",
       "20170503        80.60      22.28       4.44  \n",
       "20170504        80.50      22.40       4.44  \n",
       "20170505        79.71      22.40       4.30  \n",
       "20170508        78.31      22.32       4.23  \n",
       "\n",
       "[5 rows x 330 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.get_ts(\"open\").head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### get_ts_quarter\n",
    "- ` jaqs_fxdayu.data.Dataview.get_ts_quarter(field, symbol=\"\", start_date=0, end_date=0) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 切片查询方法：指定字段，按时间+品种查询季度数据，返回报告日期为索引，品种为columns的DataFrame\n",
    "- 注意：参数中提供的field必须为**季度数据**，可通过Dataview._get_fields('quarterly',Dataview.fields)查询数据集的字段里有哪些是季度级别数据\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|symbol|否 |string|标的代码，多标的以','隔开，如'000001.SH,600300.SH',默认查询数据集中所有标的|\n",
    "|start_date |否 |int |开始日期，默认从数据集开始日期起|\n",
    "|end_date |否 |int |结束日期，默认到数据集结束日期|\n",
    "|field |是 |string |季度数据字段,**单字段**|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>symbol</th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601992.SH</th>\n",
       "      <th>601997.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603160.SH</th>\n",
       "      <th>603858.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20140930</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5.092343e+09</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20150331</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.698335e+09</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.956667e+09</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20150630</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.622176e+09</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.815833e+08</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20150930</th>\n",
       "      <td>7.115200e+10</td>\n",
       "      <td>7.959621e+10</td>\n",
       "      <td>7.631092e+08</td>\n",
       "      <td>3.145235e+09</td>\n",
       "      <td>8.676531e+09</td>\n",
       "      <td>4.527115e+10</td>\n",
       "      <td>1.149957e+10</td>\n",
       "      <td>1.280032e+09</td>\n",
       "      <td>6.852324e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>3.567730e+11</td>\n",
       "      <td>3.977208e+10</td>\n",
       "      <td>2.590268e+10</td>\n",
       "      <td>5.605255e+09</td>\n",
       "      <td>1.074530e+11</td>\n",
       "      <td>1.066451e+09</td>\n",
       "      <td>7.322436e+08</td>\n",
       "      <td>7.774995e+09</td>\n",
       "      <td>6.262755e+09</td>\n",
       "      <td>3.174664e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20151231</th>\n",
       "      <td>9.616300e+10</td>\n",
       "      <td>1.955491e+11</td>\n",
       "      <td>1.295076e+09</td>\n",
       "      <td>4.895401e+09</td>\n",
       "      <td>1.112998e+10</td>\n",
       "      <td>5.868580e+10</td>\n",
       "      <td>1.696571e+10</td>\n",
       "      <td>1.736651e+09</td>\n",
       "      <td>1.001864e+11</td>\n",
       "      <td>3.223633e+10</td>\n",
       "      <td>...</td>\n",
       "      <td>4.743210e+11</td>\n",
       "      <td>5.981080e+10</td>\n",
       "      <td>4.092534e+10</td>\n",
       "      <td>7.705192e+09</td>\n",
       "      <td>1.451340e+11</td>\n",
       "      <td>1.604762e+09</td>\n",
       "      <td>1.119601e+09</td>\n",
       "      <td>1.165563e+10</td>\n",
       "      <td>8.158238e+09</td>\n",
       "      <td>4.196840e+09</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 330 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol         000001.SZ     000002.SZ     000008.SZ     000009.SZ  \\\n",
       "trade_date                                                           \n",
       "20140930             NaN           NaN           NaN           NaN   \n",
       "20150331             NaN           NaN           NaN           NaN   \n",
       "20150630             NaN           NaN           NaN           NaN   \n",
       "20150930    7.115200e+10  7.959621e+10  7.631092e+08  3.145235e+09   \n",
       "20151231    9.616300e+10  1.955491e+11  1.295076e+09  4.895401e+09   \n",
       "\n",
       "symbol         000027.SZ     000039.SZ     000060.SZ     000061.SZ  \\\n",
       "trade_date                                                           \n",
       "20140930             NaN           NaN           NaN           NaN   \n",
       "20150331             NaN           NaN           NaN           NaN   \n",
       "20150630             NaN           NaN           NaN           NaN   \n",
       "20150930    8.676531e+09  4.527115e+10  1.149957e+10  1.280032e+09   \n",
       "20151231    1.112998e+10  5.868580e+10  1.696571e+10  1.736651e+09   \n",
       "\n",
       "symbol         000063.SZ     000069.SZ      ...          601988.SH  \\\n",
       "trade_date                                  ...                      \n",
       "20140930             NaN           NaN      ...                NaN   \n",
       "20150331             NaN           NaN      ...                NaN   \n",
       "20150630             NaN           NaN      ...                NaN   \n",
       "20150930    6.852324e+10           NaN      ...       3.567730e+11   \n",
       "20151231    1.001864e+11  3.223633e+10      ...       4.743210e+11   \n",
       "\n",
       "symbol         601989.SH     601992.SH     601997.SH     601998.SH  \\\n",
       "trade_date                                                           \n",
       "20140930             NaN           NaN           NaN           NaN   \n",
       "20150331             NaN           NaN  1.698335e+09           NaN   \n",
       "20150630             NaN           NaN  3.622176e+09           NaN   \n",
       "20150930    3.977208e+10  2.590268e+10  5.605255e+09  1.074530e+11   \n",
       "20151231    5.981080e+10  4.092534e+10  7.705192e+09  1.451340e+11   \n",
       "\n",
       "symbol         603000.SH     603160.SH     603858.SH     603885.SH  \\\n",
       "trade_date                                                           \n",
       "20140930             NaN           NaN           NaN  5.092343e+09   \n",
       "20150331             NaN           NaN           NaN  1.956667e+09   \n",
       "20150630             NaN  4.815833e+08           NaN           NaN   \n",
       "20150930    1.066451e+09  7.322436e+08  7.774995e+09  6.262755e+09   \n",
       "20151231    1.604762e+09  1.119601e+09  1.165563e+10  8.158238e+09   \n",
       "\n",
       "symbol         603993.SH  \n",
       "trade_date                \n",
       "20140930             NaN  \n",
       "20150331             NaN  \n",
       "20150630             NaN  \n",
       "20150930    3.174664e+09  \n",
       "20151231    4.196840e+09  \n",
       "\n",
       "[5 rows x 330 columns]"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.get_ts_quarter('total_oper_rev').head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据添加"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### data_api\n",
    "- ` jaqs_fxdayu.data.Dataview.data_api `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 数据api(DataService远程数据服务类)\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<jaqs.data.dataservice.RemoteDataService at 0x7f1ed0679978>"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.data_api"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### refresh_data\n",
    "- ` jaqs_fxdayu.data.Dataview.refresh_data(end_date,data_api=None) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 将数据集中的数据更新至end_date\n",
    "- 自定义的数据（通过add_formula计算或append_df加入数据集的）无法更新\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|end_date |是  |int|更新到的截止日期，如20180411|\n",
    "|data_api |否  |jaqs.data.dataservice.RemoteDataService|DataService远程数据服务类|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>symbol</th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601992.SH</th>\n",
       "      <th>601997.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603160.SH</th>\n",
       "      <th>603858.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170928</th>\n",
       "      <td>10.88</td>\n",
       "      <td>26.41</td>\n",
       "      <td>8.62</td>\n",
       "      <td>8.99</td>\n",
       "      <td>6.47</td>\n",
       "      <td>18.18</td>\n",
       "      <td>12.05</td>\n",
       "      <td>9.03</td>\n",
       "      <td>28.15</td>\n",
       "      <td>8.19</td>\n",
       "      <td>...</td>\n",
       "      <td>4.14</td>\n",
       "      <td>6.21</td>\n",
       "      <td>6.17</td>\n",
       "      <td>14.70</td>\n",
       "      <td>6.31</td>\n",
       "      <td>13.81</td>\n",
       "      <td>93.71</td>\n",
       "      <td>67.59</td>\n",
       "      <td>14.40</td>\n",
       "      <td>7.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170929</th>\n",
       "      <td>11.11</td>\n",
       "      <td>26.25</td>\n",
       "      <td>9.03</td>\n",
       "      <td>8.99</td>\n",
       "      <td>6.45</td>\n",
       "      <td>18.15</td>\n",
       "      <td>12.13</td>\n",
       "      <td>8.82</td>\n",
       "      <td>28.30</td>\n",
       "      <td>8.17</td>\n",
       "      <td>...</td>\n",
       "      <td>4.12</td>\n",
       "      <td>6.21</td>\n",
       "      <td>6.35</td>\n",
       "      <td>14.71</td>\n",
       "      <td>6.30</td>\n",
       "      <td>13.84</td>\n",
       "      <td>95.44</td>\n",
       "      <td>67.76</td>\n",
       "      <td>14.45</td>\n",
       "      <td>7.84</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2 rows × 330 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol      000001.SZ  000002.SZ  000008.SZ  000009.SZ  000027.SZ  000039.SZ  \\\n",
       "trade_date                                                                     \n",
       "20170928        10.88      26.41       8.62       8.99       6.47      18.18   \n",
       "20170929        11.11      26.25       9.03       8.99       6.45      18.15   \n",
       "\n",
       "symbol      000060.SZ  000061.SZ  000063.SZ  000069.SZ    ...      601988.SH  \\\n",
       "trade_date                                                ...                  \n",
       "20170928        12.05       9.03      28.15       8.19    ...           4.14   \n",
       "20170929        12.13       8.82      28.30       8.17    ...           4.12   \n",
       "\n",
       "symbol      601989.SH  601992.SH  601997.SH  601998.SH  603000.SH  603160.SH  \\\n",
       "trade_date                                                                     \n",
       "20170928         6.21       6.17      14.70       6.31      13.81      93.71   \n",
       "20170929         6.21       6.35      14.71       6.30      13.84      95.44   \n",
       "\n",
       "symbol      603858.SH  603885.SH  603993.SH  \n",
       "trade_date                                   \n",
       "20170928        67.59      14.40       7.76  \n",
       "20170929        67.76      14.45       7.84  \n",
       "\n",
       "[2 rows x 330 columns]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.get_ts(\"close\").tail(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Field name [{'quarter', 'adjust_factor'}] not valid, ignore.\n",
      "Initialize config success.\n",
      "Query data...\n",
      "Query data - query...\n",
      "NOTE: price adjust method is [post adjust]\n",
      "当前请求daily...\n",
      "{'adjust_mode': None, 'fields': 'trade_status,symbol,open_adj,vwap,trade_date,index_member,low,close_adj,high,open,high_adj,low_adj,vwap_adj,index_weight,close'}\n",
      "当前请求daily...\n",
      "{'adjust_mode': 'post', 'fields': 'vwap,high,low,open,close,symbol,trade_date'}\n",
      "当前请求query_lb_dailyindicator...\n",
      "{'fields': 'pe,pb,symbol,trade_date'}\n",
      "WARNING: some data is unavailable: \n",
      "    At fields \n",
      "Query data - daily fields prepared.\n",
      "Query data - quarterly fields prepared.\n",
      "Query instrument info...\n",
      "Query adj_factor...\n",
      "Query benchmark...\n",
      "Query benchmar member info...\n",
      "Field [index_member] is overwritten.\n",
      "Field [index_weight] is overwritten.\n",
      "Query groups (industry)...\n",
      "Data has been successfully prepared.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>symbol</th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601992.SH</th>\n",
       "      <th>601997.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603160.SH</th>\n",
       "      <th>603858.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20171130</th>\n",
       "      <td>13.38</td>\n",
       "      <td>31.22</td>\n",
       "      <td>8.48</td>\n",
       "      <td>7.60</td>\n",
       "      <td>6.12</td>\n",
       "      <td>19.49</td>\n",
       "      <td>10.83</td>\n",
       "      <td>7.69</td>\n",
       "      <td>33.08</td>\n",
       "      <td>8.89</td>\n",
       "      <td>...</td>\n",
       "      <td>3.93</td>\n",
       "      <td>6.16</td>\n",
       "      <td>5.93</td>\n",
       "      <td>14.39</td>\n",
       "      <td>6.36</td>\n",
       "      <td>12.15</td>\n",
       "      <td>111.66</td>\n",
       "      <td>54.66</td>\n",
       "      <td>13.43</td>\n",
       "      <td>7.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20171201</th>\n",
       "      <td>13.00</td>\n",
       "      <td>30.73</td>\n",
       "      <td>8.59</td>\n",
       "      <td>7.58</td>\n",
       "      <td>6.10</td>\n",
       "      <td>19.81</td>\n",
       "      <td>10.92</td>\n",
       "      <td>7.72</td>\n",
       "      <td>33.56</td>\n",
       "      <td>8.85</td>\n",
       "      <td>...</td>\n",
       "      <td>3.92</td>\n",
       "      <td>6.12</td>\n",
       "      <td>5.92</td>\n",
       "      <td>14.35</td>\n",
       "      <td>6.39</td>\n",
       "      <td>12.23</td>\n",
       "      <td>110.46</td>\n",
       "      <td>54.47</td>\n",
       "      <td>13.17</td>\n",
       "      <td>7.10</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2 rows × 330 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol      000001.SZ  000002.SZ  000008.SZ  000009.SZ  000027.SZ  000039.SZ  \\\n",
       "trade_date                                                                     \n",
       "20171130        13.38      31.22       8.48       7.60       6.12      19.49   \n",
       "20171201        13.00      30.73       8.59       7.58       6.10      19.81   \n",
       "\n",
       "symbol      000060.SZ  000061.SZ  000063.SZ  000069.SZ    ...      601988.SH  \\\n",
       "trade_date                                                ...                  \n",
       "20171130        10.83       7.69      33.08       8.89    ...           3.93   \n",
       "20171201        10.92       7.72      33.56       8.85    ...           3.92   \n",
       "\n",
       "symbol      601989.SH  601992.SH  601997.SH  601998.SH  603000.SH  603160.SH  \\\n",
       "trade_date                                                                     \n",
       "20171130         6.16       5.93      14.39       6.36      12.15     111.66   \n",
       "20171201         6.12       5.92      14.35       6.39      12.23     110.46   \n",
       "\n",
       "symbol      603858.SH  603885.SH  603993.SH  \n",
       "trade_date                                   \n",
       "20171130        54.66      13.43       7.07  \n",
       "20171201        54.47      13.17       7.10  \n",
       "\n",
       "[2 rows x 330 columns]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.refresh_data(20171201)\n",
    "dv.get_ts(\"close\").tail(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### add_comp_info\n",
    "- ` jaqs_fxdayu.data.Dataview.add_comp_info(index,data_api=None) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 往数据集里添加两个新字段——symbol是否属于某指数成分股 & symbol在某指数中所占的比重如何\n",
    "- 区别于通过设置universe初始化默认下载的index_member和index_weight字段, 通过该方法新增的字段可更灵活的查询股票标的与任意指数的关系和权重\n",
    "- 新增字段名为[index]_member [index]_weight\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|index |是  |string|指数代码|\n",
    "|data_api |否  |jaqs.data.dataservice.RemoteDataService|DataService远程数据服务类|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "dv.add_comp_info('000016.SH')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>symbol</th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601992.SH</th>\n",
       "      <th>601997.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603160.SH</th>\n",
       "      <th>603858.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170502</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0.01881</td>\n",
       "      <td>0.01607</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.00459</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170503</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0.01881</td>\n",
       "      <td>0.01607</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.00459</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170504</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0.01881</td>\n",
       "      <td>0.01607</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.00459</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170505</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0.01881</td>\n",
       "      <td>0.01607</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.00459</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170508</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0.01881</td>\n",
       "      <td>0.01607</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.00459</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 330 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol      000001.SZ  000002.SZ  000008.SZ  000009.SZ  000027.SZ  000039.SZ  \\\n",
       "trade_date                                                                     \n",
       "20170502          NaN        NaN        NaN        NaN        NaN        NaN   \n",
       "20170503          NaN        NaN        NaN        NaN        NaN        NaN   \n",
       "20170504          NaN        NaN        NaN        NaN        NaN        NaN   \n",
       "20170505          NaN        NaN        NaN        NaN        NaN        NaN   \n",
       "20170508          NaN        NaN        NaN        NaN        NaN        NaN   \n",
       "\n",
       "symbol      000060.SZ  000061.SZ  000063.SZ  000069.SZ    ...      601988.SH  \\\n",
       "trade_date                                                ...                  \n",
       "20170502          NaN        NaN        NaN        NaN    ...        0.01881   \n",
       "20170503          NaN        NaN        NaN        NaN    ...        0.01881   \n",
       "20170504          NaN        NaN        NaN        NaN    ...        0.01881   \n",
       "20170505          NaN        NaN        NaN        NaN    ...        0.01881   \n",
       "20170508          NaN        NaN        NaN        NaN    ...        0.01881   \n",
       "\n",
       "symbol      601989.SH  601992.SH  601997.SH  601998.SH  603000.SH  603160.SH  \\\n",
       "trade_date                                                                     \n",
       "20170502      0.01607        NaN        NaN    0.00459        NaN        NaN   \n",
       "20170503      0.01607        NaN        NaN    0.00459        NaN        NaN   \n",
       "20170504      0.01607        NaN        NaN    0.00459        NaN        NaN   \n",
       "20170505      0.01607        NaN        NaN    0.00459        NaN        NaN   \n",
       "20170508      0.01607        NaN        NaN    0.00459        NaN        NaN   \n",
       "\n",
       "symbol      603858.SH  603885.SH  603993.SH  \n",
       "trade_date                                   \n",
       "20170502          NaN        NaN        NaN  \n",
       "20170503          NaN        NaN        NaN  \n",
       "20170504          NaN        NaN        NaN  \n",
       "20170505          NaN        NaN        NaN  \n",
       "20170508          NaN        NaN        NaN  \n",
       "\n",
       "[5 rows x 330 columns]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.get_ts(\"000016.SH_weight\").head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### add_field\n",
    "- ` jaqs_fxdayu.data.Dataview.add_field(field_name, data_api=None, report_type='408001000') `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 通过远程数据源往数据集里新增新字段（需确保远程数据源中含有该字段的数据）\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|field_name|是  |string|待新增的字段名|\n",
    "|data_api |否  |jaqs.data.dataservice.RemoteDataService|DataService远程数据服务类|\n",
    "|report_type |否 | string |财报类型。财报类型共有以下几类：'408001000':合并报表；'408002000':合并报表（单季度）；'408003000':合并报表（单季度调整）；'408004000':合并报表（调整）；'408005000':合并报表（更正前）；'408006000':母公司报表；'408007000':母公司报表（单季度）；'408008000':母公司报表（单季度调整）；'408009000':母公司报表（调整）；'408010000':母公司报表（更正前）。 默认为'408001000':合并报表|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Query data - query...\n",
      "NOTE: price adjust method is [post adjust]\n",
      "当前请求daily...\n",
      "{'adjust_mode': None, 'fields': 'volume,trade_status,symbol,trade_date'}\n",
      "Query data - daily fields prepared.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.add_field(\"volume\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>symbol</th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601992.SH</th>\n",
       "      <th>601997.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603160.SH</th>\n",
       "      <th>603858.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170502</th>\n",
       "      <td>31102610.0</td>\n",
       "      <td>18442367.0</td>\n",
       "      <td>9684786.0</td>\n",
       "      <td>25497861.0</td>\n",
       "      <td>6432105.0</td>\n",
       "      <td>6327586.0</td>\n",
       "      <td>8965345.0</td>\n",
       "      <td>4378121.0</td>\n",
       "      <td>19238235.0</td>\n",
       "      <td>27143591.0</td>\n",
       "      <td>...</td>\n",
       "      <td>66093550.0</td>\n",
       "      <td>66530694.0</td>\n",
       "      <td>544839719.0</td>\n",
       "      <td>10925965.0</td>\n",
       "      <td>17520651.0</td>\n",
       "      <td>3119911.0</td>\n",
       "      <td>2091792.0</td>\n",
       "      <td>818200.0</td>\n",
       "      <td>926950.0</td>\n",
       "      <td>88555440.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170503</th>\n",
       "      <td>28031077.0</td>\n",
       "      <td>26926611.0</td>\n",
       "      <td>7763618.0</td>\n",
       "      <td>18416240.0</td>\n",
       "      <td>10746444.0</td>\n",
       "      <td>6107544.0</td>\n",
       "      <td>13106532.0</td>\n",
       "      <td>4834657.0</td>\n",
       "      <td>34074547.0</td>\n",
       "      <td>38599137.0</td>\n",
       "      <td>...</td>\n",
       "      <td>84611551.0</td>\n",
       "      <td>86231763.0</td>\n",
       "      <td>516934503.0</td>\n",
       "      <td>11688295.0</td>\n",
       "      <td>23738285.0</td>\n",
       "      <td>5159855.0</td>\n",
       "      <td>1346232.0</td>\n",
       "      <td>854976.0</td>\n",
       "      <td>1006828.0</td>\n",
       "      <td>58089924.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170504</th>\n",
       "      <td>69651707.0</td>\n",
       "      <td>17846705.0</td>\n",
       "      <td>8177165.0</td>\n",
       "      <td>15236008.0</td>\n",
       "      <td>7574795.0</td>\n",
       "      <td>7298552.0</td>\n",
       "      <td>25223485.0</td>\n",
       "      <td>5413535.0</td>\n",
       "      <td>33992154.0</td>\n",
       "      <td>17511452.0</td>\n",
       "      <td>...</td>\n",
       "      <td>74607306.0</td>\n",
       "      <td>105007184.0</td>\n",
       "      <td>606859878.0</td>\n",
       "      <td>15697719.0</td>\n",
       "      <td>38672243.0</td>\n",
       "      <td>6574210.0</td>\n",
       "      <td>823415.0</td>\n",
       "      <td>1148000.0</td>\n",
       "      <td>1139450.0</td>\n",
       "      <td>72505821.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170505</th>\n",
       "      <td>62370085.0</td>\n",
       "      <td>11655082.0</td>\n",
       "      <td>17977630.0</td>\n",
       "      <td>19831245.0</td>\n",
       "      <td>7462745.0</td>\n",
       "      <td>13769005.0</td>\n",
       "      <td>14733040.0</td>\n",
       "      <td>4027676.0</td>\n",
       "      <td>32366194.0</td>\n",
       "      <td>20326215.0</td>\n",
       "      <td>...</td>\n",
       "      <td>175567864.0</td>\n",
       "      <td>139296698.0</td>\n",
       "      <td>318657662.0</td>\n",
       "      <td>15302449.0</td>\n",
       "      <td>29776701.0</td>\n",
       "      <td>7457617.0</td>\n",
       "      <td>1135698.0</td>\n",
       "      <td>1159354.0</td>\n",
       "      <td>2677492.0</td>\n",
       "      <td>69479848.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170508</th>\n",
       "      <td>46008989.0</td>\n",
       "      <td>18399614.0</td>\n",
       "      <td>8826250.0</td>\n",
       "      <td>19415168.0</td>\n",
       "      <td>9090216.0</td>\n",
       "      <td>5051955.0</td>\n",
       "      <td>14364021.0</td>\n",
       "      <td>3932185.0</td>\n",
       "      <td>29396110.0</td>\n",
       "      <td>29515727.0</td>\n",
       "      <td>...</td>\n",
       "      <td>138086728.0</td>\n",
       "      <td>144402061.0</td>\n",
       "      <td>383459440.0</td>\n",
       "      <td>14624454.0</td>\n",
       "      <td>28293010.0</td>\n",
       "      <td>5304703.0</td>\n",
       "      <td>1563932.0</td>\n",
       "      <td>1425800.0</td>\n",
       "      <td>1799118.0</td>\n",
       "      <td>47210293.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 330 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol       000001.SZ   000002.SZ   000008.SZ   000009.SZ   000027.SZ  \\\n",
       "trade_date                                                               \n",
       "20170502    31102610.0  18442367.0   9684786.0  25497861.0   6432105.0   \n",
       "20170503    28031077.0  26926611.0   7763618.0  18416240.0  10746444.0   \n",
       "20170504    69651707.0  17846705.0   8177165.0  15236008.0   7574795.0   \n",
       "20170505    62370085.0  11655082.0  17977630.0  19831245.0   7462745.0   \n",
       "20170508    46008989.0  18399614.0   8826250.0  19415168.0   9090216.0   \n",
       "\n",
       "symbol       000039.SZ   000060.SZ  000061.SZ   000063.SZ   000069.SZ  \\\n",
       "trade_date                                                              \n",
       "20170502     6327586.0   8965345.0  4378121.0  19238235.0  27143591.0   \n",
       "20170503     6107544.0  13106532.0  4834657.0  34074547.0  38599137.0   \n",
       "20170504     7298552.0  25223485.0  5413535.0  33992154.0  17511452.0   \n",
       "20170505    13769005.0  14733040.0  4027676.0  32366194.0  20326215.0   \n",
       "20170508     5051955.0  14364021.0  3932185.0  29396110.0  29515727.0   \n",
       "\n",
       "symbol         ...        601988.SH    601989.SH    601992.SH   601997.SH  \\\n",
       "trade_date     ...                                                          \n",
       "20170502       ...       66093550.0   66530694.0  544839719.0  10925965.0   \n",
       "20170503       ...       84611551.0   86231763.0  516934503.0  11688295.0   \n",
       "20170504       ...       74607306.0  105007184.0  606859878.0  15697719.0   \n",
       "20170505       ...      175567864.0  139296698.0  318657662.0  15302449.0   \n",
       "20170508       ...      138086728.0  144402061.0  383459440.0  14624454.0   \n",
       "\n",
       "symbol       601998.SH  603000.SH  603160.SH  603858.SH  603885.SH   603993.SH  \n",
       "trade_date                                                                      \n",
       "20170502    17520651.0  3119911.0  2091792.0   818200.0   926950.0  88555440.0  \n",
       "20170503    23738285.0  5159855.0  1346232.0   854976.0  1006828.0  58089924.0  \n",
       "20170504    38672243.0  6574210.0   823415.0  1148000.0  1139450.0  72505821.0  \n",
       "20170505    29776701.0  7457617.0  1135698.0  1159354.0  2677492.0  69479848.0  \n",
       "20170508    28293010.0  5304703.0  1563932.0  1425800.0  1799118.0  47210293.0  \n",
       "\n",
       "[5 rows x 330 columns]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.get_ts(\"volume\").head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "### add_formula\n",
    "\n",
    "- ` jaqs_fxdayu.data.Dataview.add_formula(field_name,formula,is_quarterly,add_data=False,overwrite=True,formula_func_name_style='camel',data_api=None,register_funcs = None,within_index=True)  `\n",
    "\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 通过表达式定义因子\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|field_name|是  |string|自定义的因子名称|\n",
    "|formula |是  |string|因子表达式|\n",
    "|is_quarterly |是  |bool|公式中的季度数据是否按季频周期提取（若为True，则季度数据时间序列相关计算在季频下进行，否则处理到日频下进行计算。日频数据不会受此参数影响）|\n",
    "|add_data |否  |bool|是否将最终结果添加到dataview数据集中，默认不添加|\n",
    "|overwrite |否  |bool|若因子名称(field_name)与数据集中已有的字段冲突，是否覆盖。仅在add_data=True时生效，默认覆盖|\n",
    "|formula_func_name_style |否 |string {'upper', 'lower'， 'camel'}|表达式中用到的函数名大小写规则,默认为'camel'|\n",
    "|data_api |否 |jaqs.data.dataservice.RemoteDataService|DataService远程数据服务类，若因子表达式中使用到的字段在当前数据集中没有，会通过该api自动从网络请求相应字段添加到当前数据集当中|\n",
    "|register_funcs |否 |dict of function|因子表达式中用到的自定义方法所组成的dict,如{\"name1\":func1，\"name2\":func2}|\n",
    "|with_index |否 |bool|执行因子表达式计算的时候 是否只考虑指数成分股。仅在数据集字段中含有index_member时生效, 默认为True|"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**示例一：**\n",
    "直接返回"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>symbol</th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601992.SH</th>\n",
       "      <th>601997.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603160.SH</th>\n",
       "      <th>603858.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170502</th>\n",
       "      <td>-0.015419</td>\n",
       "      <td>-0.064783</td>\n",
       "      <td>-0.076389</td>\n",
       "      <td>-0.057860</td>\n",
       "      <td>0.007246</td>\n",
       "      <td>-0.011707</td>\n",
       "      <td>-0.074910</td>\n",
       "      <td>-0.154265</td>\n",
       "      <td>0.037647</td>\n",
       "      <td>0.120332</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.027322</td>\n",
       "      <td>-0.034578</td>\n",
       "      <td>0.708075</td>\n",
       "      <td>-0.058859</td>\n",
       "      <td>-0.099548</td>\n",
       "      <td>-0.107944</td>\n",
       "      <td>0.032925</td>\n",
       "      <td>-0.084092</td>\n",
       "      <td>-0.032118</td>\n",
       "      <td>0.008929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170503</th>\n",
       "      <td>-0.028353</td>\n",
       "      <td>-0.083576</td>\n",
       "      <td>-0.093822</td>\n",
       "      <td>-0.066521</td>\n",
       "      <td>-0.036517</td>\n",
       "      <td>-0.006211</td>\n",
       "      <td>-0.089767</td>\n",
       "      <td>-0.162579</td>\n",
       "      <td>0.050708</td>\n",
       "      <td>0.093151</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.045946</td>\n",
       "      <td>-0.076613</td>\n",
       "      <td>0.633047</td>\n",
       "      <td>-0.101772</td>\n",
       "      <td>-0.119225</td>\n",
       "      <td>-0.105232</td>\n",
       "      <td>0.030166</td>\n",
       "      <td>-0.089233</td>\n",
       "      <td>-0.038296</td>\n",
       "      <td>-0.043550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170504</th>\n",
       "      <td>-0.051031</td>\n",
       "      <td>-0.075802</td>\n",
       "      <td>-0.113611</td>\n",
       "      <td>-0.085653</td>\n",
       "      <td>-0.057613</td>\n",
       "      <td>-0.043135</td>\n",
       "      <td>-0.126427</td>\n",
       "      <td>-0.179695</td>\n",
       "      <td>0.028852</td>\n",
       "      <td>0.076716</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.040761</td>\n",
       "      <td>-0.109211</td>\n",
       "      <td>0.543860</td>\n",
       "      <td>-0.087668</td>\n",
       "      <td>-0.131657</td>\n",
       "      <td>-0.146903</td>\n",
       "      <td>0.001239</td>\n",
       "      <td>-0.108997</td>\n",
       "      <td>-0.048739</td>\n",
       "      <td>-0.151733</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170505</th>\n",
       "      <td>-0.061957</td>\n",
       "      <td>-0.091390</td>\n",
       "      <td>-0.179543</td>\n",
       "      <td>-0.114684</td>\n",
       "      <td>-0.058172</td>\n",
       "      <td>-0.095238</td>\n",
       "      <td>-0.128748</td>\n",
       "      <td>-0.185484</td>\n",
       "      <td>0.017929</td>\n",
       "      <td>0.059140</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.032787</td>\n",
       "      <td>-0.132199</td>\n",
       "      <td>0.377660</td>\n",
       "      <td>-0.109549</td>\n",
       "      <td>-0.132244</td>\n",
       "      <td>-0.162114</td>\n",
       "      <td>-0.038807</td>\n",
       "      <td>-0.127279</td>\n",
       "      <td>-0.039676</td>\n",
       "      <td>-0.162778</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170508</th>\n",
       "      <td>-0.068478</td>\n",
       "      <td>-0.112019</td>\n",
       "      <td>-0.194934</td>\n",
       "      <td>-0.136120</td>\n",
       "      <td>-0.075000</td>\n",
       "      <td>-0.095668</td>\n",
       "      <td>-0.129061</td>\n",
       "      <td>-0.178796</td>\n",
       "      <td>-0.013326</td>\n",
       "      <td>0.042610</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.019231</td>\n",
       "      <td>-0.161880</td>\n",
       "      <td>0.133871</td>\n",
       "      <td>-0.127647</td>\n",
       "      <td>-0.130370</td>\n",
       "      <td>-0.175264</td>\n",
       "      <td>-0.002776</td>\n",
       "      <td>-0.132699</td>\n",
       "      <td>-0.058723</td>\n",
       "      <td>-0.152260</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 330 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol      000001.SZ  000002.SZ  000008.SZ  000009.SZ  000027.SZ  000039.SZ  \\\n",
       "trade_date                                                                     \n",
       "20170502    -0.015419  -0.064783  -0.076389  -0.057860   0.007246  -0.011707   \n",
       "20170503    -0.028353  -0.083576  -0.093822  -0.066521  -0.036517  -0.006211   \n",
       "20170504    -0.051031  -0.075802  -0.113611  -0.085653  -0.057613  -0.043135   \n",
       "20170505    -0.061957  -0.091390  -0.179543  -0.114684  -0.058172  -0.095238   \n",
       "20170508    -0.068478  -0.112019  -0.194934  -0.136120  -0.075000  -0.095668   \n",
       "\n",
       "symbol      000060.SZ  000061.SZ  000063.SZ  000069.SZ    ...      601988.SH  \\\n",
       "trade_date                                                ...                  \n",
       "20170502    -0.074910  -0.154265   0.037647   0.120332    ...      -0.027322   \n",
       "20170503    -0.089767  -0.162579   0.050708   0.093151    ...      -0.045946   \n",
       "20170504    -0.126427  -0.179695   0.028852   0.076716    ...      -0.040761   \n",
       "20170505    -0.128748  -0.185484   0.017929   0.059140    ...      -0.032787   \n",
       "20170508    -0.129061  -0.178796  -0.013326   0.042610    ...      -0.019231   \n",
       "\n",
       "symbol      601989.SH  601992.SH  601997.SH  601998.SH  603000.SH  603160.SH  \\\n",
       "trade_date                                                                     \n",
       "20170502    -0.034578   0.708075  -0.058859  -0.099548  -0.107944   0.032925   \n",
       "20170503    -0.076613   0.633047  -0.101772  -0.119225  -0.105232   0.030166   \n",
       "20170504    -0.109211   0.543860  -0.087668  -0.131657  -0.146903   0.001239   \n",
       "20170505    -0.132199   0.377660  -0.109549  -0.132244  -0.162114  -0.038807   \n",
       "20170508    -0.161880   0.133871  -0.127647  -0.130370  -0.175264  -0.002776   \n",
       "\n",
       "symbol      603858.SH  603885.SH  603993.SH  \n",
       "trade_date                                   \n",
       "20170502    -0.084092  -0.032118   0.008929  \n",
       "20170503    -0.089233  -0.038296  -0.043550  \n",
       "20170504    -0.108997  -0.048739  -0.151733  \n",
       "20170505    -0.127279  -0.039676  -0.162778  \n",
       "20170508    -0.132699  -0.058723  -0.152260  \n",
       "\n",
       "[5 rows x 330 columns]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.add_formula(\"momentum\", \"Return(close_adj, 20)\", is_quarterly=False).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**示例二：**\n",
    "添加到数据集里，则计算结果之后可以反复调用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>symbol</th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601992.SH</th>\n",
       "      <th>601997.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603160.SH</th>\n",
       "      <th>603858.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170502</th>\n",
       "      <td>-0.015419</td>\n",
       "      <td>-0.064783</td>\n",
       "      <td>-0.076389</td>\n",
       "      <td>-0.057860</td>\n",
       "      <td>0.007246</td>\n",
       "      <td>-0.011707</td>\n",
       "      <td>-0.074910</td>\n",
       "      <td>-0.154265</td>\n",
       "      <td>0.037647</td>\n",
       "      <td>0.120332</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.027322</td>\n",
       "      <td>-0.034578</td>\n",
       "      <td>0.708075</td>\n",
       "      <td>-0.058859</td>\n",
       "      <td>-0.099548</td>\n",
       "      <td>-0.107944</td>\n",
       "      <td>0.032925</td>\n",
       "      <td>-0.084092</td>\n",
       "      <td>-0.032118</td>\n",
       "      <td>0.008929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170503</th>\n",
       "      <td>-0.028353</td>\n",
       "      <td>-0.083576</td>\n",
       "      <td>-0.093822</td>\n",
       "      <td>-0.066521</td>\n",
       "      <td>-0.036517</td>\n",
       "      <td>-0.006211</td>\n",
       "      <td>-0.089767</td>\n",
       "      <td>-0.162579</td>\n",
       "      <td>0.050708</td>\n",
       "      <td>0.093151</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.045946</td>\n",
       "      <td>-0.076613</td>\n",
       "      <td>0.633047</td>\n",
       "      <td>-0.101772</td>\n",
       "      <td>-0.119225</td>\n",
       "      <td>-0.105232</td>\n",
       "      <td>0.030166</td>\n",
       "      <td>-0.089233</td>\n",
       "      <td>-0.038296</td>\n",
       "      <td>-0.043550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170504</th>\n",
       "      <td>-0.051031</td>\n",
       "      <td>-0.075802</td>\n",
       "      <td>-0.113611</td>\n",
       "      <td>-0.085653</td>\n",
       "      <td>-0.057613</td>\n",
       "      <td>-0.043135</td>\n",
       "      <td>-0.126427</td>\n",
       "      <td>-0.179695</td>\n",
       "      <td>0.028852</td>\n",
       "      <td>0.076716</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.040761</td>\n",
       "      <td>-0.109211</td>\n",
       "      <td>0.543860</td>\n",
       "      <td>-0.087668</td>\n",
       "      <td>-0.131657</td>\n",
       "      <td>-0.146903</td>\n",
       "      <td>0.001239</td>\n",
       "      <td>-0.108997</td>\n",
       "      <td>-0.048739</td>\n",
       "      <td>-0.151733</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170505</th>\n",
       "      <td>-0.061957</td>\n",
       "      <td>-0.091390</td>\n",
       "      <td>-0.179543</td>\n",
       "      <td>-0.114684</td>\n",
       "      <td>-0.058172</td>\n",
       "      <td>-0.095238</td>\n",
       "      <td>-0.128748</td>\n",
       "      <td>-0.185484</td>\n",
       "      <td>0.017929</td>\n",
       "      <td>0.059140</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.032787</td>\n",
       "      <td>-0.132199</td>\n",
       "      <td>0.377660</td>\n",
       "      <td>-0.109549</td>\n",
       "      <td>-0.132244</td>\n",
       "      <td>-0.162114</td>\n",
       "      <td>-0.038807</td>\n",
       "      <td>-0.127279</td>\n",
       "      <td>-0.039676</td>\n",
       "      <td>-0.162778</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170508</th>\n",
       "      <td>-0.068478</td>\n",
       "      <td>-0.112019</td>\n",
       "      <td>-0.194934</td>\n",
       "      <td>-0.136120</td>\n",
       "      <td>-0.075000</td>\n",
       "      <td>-0.095668</td>\n",
       "      <td>-0.129061</td>\n",
       "      <td>-0.178796</td>\n",
       "      <td>-0.013326</td>\n",
       "      <td>0.042610</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.019231</td>\n",
       "      <td>-0.161880</td>\n",
       "      <td>0.133871</td>\n",
       "      <td>-0.127647</td>\n",
       "      <td>-0.130370</td>\n",
       "      <td>-0.175264</td>\n",
       "      <td>-0.002776</td>\n",
       "      <td>-0.132699</td>\n",
       "      <td>-0.058723</td>\n",
       "      <td>-0.152260</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 330 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol      000001.SZ  000002.SZ  000008.SZ  000009.SZ  000027.SZ  000039.SZ  \\\n",
       "trade_date                                                                     \n",
       "20170502    -0.015419  -0.064783  -0.076389  -0.057860   0.007246  -0.011707   \n",
       "20170503    -0.028353  -0.083576  -0.093822  -0.066521  -0.036517  -0.006211   \n",
       "20170504    -0.051031  -0.075802  -0.113611  -0.085653  -0.057613  -0.043135   \n",
       "20170505    -0.061957  -0.091390  -0.179543  -0.114684  -0.058172  -0.095238   \n",
       "20170508    -0.068478  -0.112019  -0.194934  -0.136120  -0.075000  -0.095668   \n",
       "\n",
       "symbol      000060.SZ  000061.SZ  000063.SZ  000069.SZ    ...      601988.SH  \\\n",
       "trade_date                                                ...                  \n",
       "20170502    -0.074910  -0.154265   0.037647   0.120332    ...      -0.027322   \n",
       "20170503    -0.089767  -0.162579   0.050708   0.093151    ...      -0.045946   \n",
       "20170504    -0.126427  -0.179695   0.028852   0.076716    ...      -0.040761   \n",
       "20170505    -0.128748  -0.185484   0.017929   0.059140    ...      -0.032787   \n",
       "20170508    -0.129061  -0.178796  -0.013326   0.042610    ...      -0.019231   \n",
       "\n",
       "symbol      601989.SH  601992.SH  601997.SH  601998.SH  603000.SH  603160.SH  \\\n",
       "trade_date                                                                     \n",
       "20170502    -0.034578   0.708075  -0.058859  -0.099548  -0.107944   0.032925   \n",
       "20170503    -0.076613   0.633047  -0.101772  -0.119225  -0.105232   0.030166   \n",
       "20170504    -0.109211   0.543860  -0.087668  -0.131657  -0.146903   0.001239   \n",
       "20170505    -0.132199   0.377660  -0.109549  -0.132244  -0.162114  -0.038807   \n",
       "20170508    -0.161880   0.133871  -0.127647  -0.130370  -0.175264  -0.002776   \n",
       "\n",
       "symbol      603858.SH  603885.SH  603993.SH  \n",
       "trade_date                                   \n",
       "20170502    -0.084092  -0.032118   0.008929  \n",
       "20170503    -0.089233  -0.038296  -0.043550  \n",
       "20170504    -0.108997  -0.048739  -0.151733  \n",
       "20170505    -0.127279  -0.039676  -0.162778  \n",
       "20170508    -0.132699  -0.058723  -0.152260  \n",
       "\n",
       "[5 rows x 330 columns]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.add_formula(\"momentum\", \"Return(close_adj, 20)\", is_quarterly=False, add_data=True)\n",
    "dv.get_ts(\"momentum\").head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**示例三：**\n",
    "通过事先定义并注册一些因子计算中需要的函数方法，完成更高自由度的因子计算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>symbol</th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601992.SH</th>\n",
       "      <th>601997.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603160.SH</th>\n",
       "      <th>603858.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170502</th>\n",
       "      <td>902.763220</td>\n",
       "      <td>2486.337268</td>\n",
       "      <td>222.702230</td>\n",
       "      <td>86.694747</td>\n",
       "      <td>96.210407</td>\n",
       "      <td>384.093500</td>\n",
       "      <td>243.687558</td>\n",
       "      <td>213.240494</td>\n",
       "      <td>298.533382</td>\n",
       "      <td>321.033510</td>\n",
       "      <td>...</td>\n",
       "      <td>5.618304</td>\n",
       "      <td>12.228624</td>\n",
       "      <td>16.337667</td>\n",
       "      <td>15.853791</td>\n",
       "      <td>8.049842</td>\n",
       "      <td>61.962369</td>\n",
       "      <td>90.623181</td>\n",
       "      <td>81.381230</td>\n",
       "      <td>45.732059</td>\n",
       "      <td>14.250433</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170503</th>\n",
       "      <td>901.693012</td>\n",
       "      <td>2458.607759</td>\n",
       "      <td>220.011542</td>\n",
       "      <td>86.274281</td>\n",
       "      <td>95.764841</td>\n",
       "      <td>382.711958</td>\n",
       "      <td>242.819760</td>\n",
       "      <td>209.993794</td>\n",
       "      <td>299.424894</td>\n",
       "      <td>320.170244</td>\n",
       "      <td>...</td>\n",
       "      <td>5.610843</td>\n",
       "      <td>12.093762</td>\n",
       "      <td>16.388825</td>\n",
       "      <td>15.822053</td>\n",
       "      <td>7.996918</td>\n",
       "      <td>61.652794</td>\n",
       "      <td>92.037297</td>\n",
       "      <td>81.146152</td>\n",
       "      <td>45.665220</td>\n",
       "      <td>14.262870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170504</th>\n",
       "      <td>898.648253</td>\n",
       "      <td>2434.327687</td>\n",
       "      <td>217.509487</td>\n",
       "      <td>85.953173</td>\n",
       "      <td>95.348827</td>\n",
       "      <td>380.921464</td>\n",
       "      <td>241.525309</td>\n",
       "      <td>207.048611</td>\n",
       "      <td>300.227209</td>\n",
       "      <td>319.209255</td>\n",
       "      <td>...</td>\n",
       "      <td>5.600827</td>\n",
       "      <td>11.952804</td>\n",
       "      <td>16.444759</td>\n",
       "      <td>15.784386</td>\n",
       "      <td>7.943142</td>\n",
       "      <td>61.251215</td>\n",
       "      <td>93.216093</td>\n",
       "      <td>80.872100</td>\n",
       "      <td>45.594402</td>\n",
       "      <td>14.249688</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170505</th>\n",
       "      <td>893.835609</td>\n",
       "      <td>2412.493048</td>\n",
       "      <td>214.370868</td>\n",
       "      <td>85.402007</td>\n",
       "      <td>94.885973</td>\n",
       "      <td>377.704290</td>\n",
       "      <td>240.001648</td>\n",
       "      <td>204.469036</td>\n",
       "      <td>300.466335</td>\n",
       "      <td>317.786651</td>\n",
       "      <td>...</td>\n",
       "      <td>5.592535</td>\n",
       "      <td>11.798688</td>\n",
       "      <td>16.461484</td>\n",
       "      <td>15.702713</td>\n",
       "      <td>7.890575</td>\n",
       "      <td>60.693946</td>\n",
       "      <td>93.950437</td>\n",
       "      <td>80.487844</td>\n",
       "      <td>45.588495</td>\n",
       "      <td>14.194258</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170508</th>\n",
       "      <td>888.101823</td>\n",
       "      <td>2388.403014</td>\n",
       "      <td>210.622674</td>\n",
       "      <td>84.588481</td>\n",
       "      <td>94.241335</td>\n",
       "      <td>373.764215</td>\n",
       "      <td>238.650220</td>\n",
       "      <td>202.458126</td>\n",
       "      <td>299.352026</td>\n",
       "      <td>316.098221</td>\n",
       "      <td>...</td>\n",
       "      <td>5.591171</td>\n",
       "      <td>11.616677</td>\n",
       "      <td>16.285680</td>\n",
       "      <td>15.569446</td>\n",
       "      <td>7.848774</td>\n",
       "      <td>60.111181</td>\n",
       "      <td>94.615652</td>\n",
       "      <td>79.885080</td>\n",
       "      <td>45.523878</td>\n",
       "      <td>14.133393</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 330 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol       000001.SZ    000002.SZ   000008.SZ  000009.SZ  000027.SZ  \\\n",
       "trade_date                                                              \n",
       "20170502    902.763220  2486.337268  222.702230  86.694747  96.210407   \n",
       "20170503    901.693012  2458.607759  220.011542  86.274281  95.764841   \n",
       "20170504    898.648253  2434.327687  217.509487  85.953173  95.348827   \n",
       "20170505    893.835609  2412.493048  214.370868  85.402007  94.885973   \n",
       "20170508    888.101823  2388.403014  210.622674  84.588481  94.241335   \n",
       "\n",
       "symbol       000039.SZ   000060.SZ   000061.SZ   000063.SZ   000069.SZ  \\\n",
       "trade_date                                                               \n",
       "20170502    384.093500  243.687558  213.240494  298.533382  321.033510   \n",
       "20170503    382.711958  242.819760  209.993794  299.424894  320.170244   \n",
       "20170504    380.921464  241.525309  207.048611  300.227209  319.209255   \n",
       "20170505    377.704290  240.001648  204.469036  300.466335  317.786651   \n",
       "20170508    373.764215  238.650220  202.458126  299.352026  316.098221   \n",
       "\n",
       "symbol        ...      601988.SH  601989.SH  601992.SH  601997.SH  601998.SH  \\\n",
       "trade_date    ...                                                              \n",
       "20170502      ...       5.618304  12.228624  16.337667  15.853791   8.049842   \n",
       "20170503      ...       5.610843  12.093762  16.388825  15.822053   7.996918   \n",
       "20170504      ...       5.600827  11.952804  16.444759  15.784386   7.943142   \n",
       "20170505      ...       5.592535  11.798688  16.461484  15.702713   7.890575   \n",
       "20170508      ...       5.591171  11.616677  16.285680  15.569446   7.848774   \n",
       "\n",
       "symbol      603000.SH  603160.SH  603858.SH  603885.SH  603993.SH  \n",
       "trade_date                                                         \n",
       "20170502    61.962369  90.623181  81.381230  45.732059  14.250433  \n",
       "20170503    61.652794  92.037297  81.146152  45.665220  14.262870  \n",
       "20170504    61.251215  93.216093  80.872100  45.594402  14.249688  \n",
       "20170505    60.693946  93.950437  80.487844  45.588495  14.194258  \n",
       "20170508    60.111181  94.615652  79.885080  45.523878  14.133393  \n",
       "\n",
       "[5 rows x 330 columns]"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 定义指数平均计算函数-传入一个时间为索引,股票为columns的Dataframe,计算其指数平均序列\n",
    "# SMAtoday=m/n * Pricetoday + ( n-m )/n * SMAyesterday;\n",
    "def sma(df, n, m):\n",
    "    a = n / m - 1\n",
    "    r = df.ewm(com=a, axis=0, adjust=False)\n",
    "    return r.mean()\n",
    "\n",
    "dv.add_formula(\"double_SMA\",\"SMA(SMA(close_adj,3,1),3,1)\",\n",
    "               is_quarterly=False,\n",
    "               add_data=True,\n",
    "               register_funcs={\"SMA\":sma}).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### func_doc\n",
    "- ` jaqs_fxdayu.data.Dataview.func_doc `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- add_formula 支持的内置公式查询方法\n",
    "- 查询方法包括：\n",
    "  - func_doc.doc # 完整文档\n",
    "  - func_doc.funcs # 函数一览\n",
    "  - func_doc.types # 函数类型\n",
    "  - func_doc.descriptions # 函数描述\n",
    "  - func_doc.search_by_type(type) # 根据函数类型查询该类型下所有的函数 type-函数类型(string) \n",
    "  - func_doc.search_by_description(description) # 根据函数描述查询可能符合该描述的所有的函数 description-函数描述(string) \n",
    "  - dv.func_doc.search_by_func(func,precise) # 根据函数名查询该函数 func-函数方法(string) precise-是否模糊查询(bool) \n",
    "  \n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分类</th>\n",
       "      <th>说明</th>\n",
       "      <th>公式</th>\n",
       "      <th>示例</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>四则运算</td>\n",
       "      <td>加法运算</td>\n",
       "      <td>+</td>\n",
       "      <td>close + open</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>四则运算</td>\n",
       "      <td>减法运算</td>\n",
       "      <td>-</td>\n",
       "      <td>close - open</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>四则运算</td>\n",
       "      <td>乘法运算</td>\n",
       "      <td>*</td>\n",
       "      <td>vwap * volume</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>四则运算</td>\n",
       "      <td>除法运算</td>\n",
       "      <td>/</td>\n",
       "      <td>close / open</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>基本数学函数</td>\n",
       "      <td>符号函数，返回值为{-1, 0, 1}</td>\n",
       "      <td>Sign(x)</td>\n",
       "      <td>Sign(close-open)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       分类                   说明       公式                示例\n",
       "0    四则运算                 加法运算        +      close + open\n",
       "1    四则运算                 减法运算        -      close - open\n",
       "2    四则运算                 乘法运算        *     vwap * volume\n",
       "3    四则运算                 除法运算        /      close / open\n",
       "4  基本数学函数  符号函数，返回值为{-1, 0, 1}  Sign(x)  Sign(close-open)"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 完整文档-前5条\n",
    "dv.func_doc.doc.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['+', '-'], dtype=object)"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 函数一览-前两个\n",
    "dv.func_doc.funcs[:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['四则运算', '基本数学函数'], dtype=object)"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 函数类型-前两个\n",
    "dv.func_doc.types[:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['加法运算', '减法运算'], dtype=object)"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 函数描述-前两个\n",
    "dv.func_doc.descriptions[:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分类</th>\n",
       "      <th>说明</th>\n",
       "      <th>公式</th>\n",
       "      <th>示例</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>基本数学函数</td>\n",
       "      <td>符号函数，返回值为{-1, 0, 1}</td>\n",
       "      <td>Sign(x)</td>\n",
       "      <td>Sign(close-open)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>基本数学函数</td>\n",
       "      <td>绝对值函数</td>\n",
       "      <td>Abs(x)</td>\n",
       "      <td>Abs(close-open)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>基本数学函数</td>\n",
       "      <td>自然对数</td>\n",
       "      <td>Log(x)</td>\n",
       "      <td>Log(close/open)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>基本数学函数</td>\n",
       "      <td>对x取负</td>\n",
       "      <td>-x</td>\n",
       "      <td>-close</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>基本数学函数</td>\n",
       "      <td>幂函数</td>\n",
       "      <td>^</td>\n",
       "      <td>close ^ 2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>基本数学函数</td>\n",
       "      <td>幂函数x^y</td>\n",
       "      <td>Pow(x,y)</td>\n",
       "      <td>Pow(close,2)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>基本数学函数</td>\n",
       "      <td>保持符号的幂函数，等价于Sign(x) * (Abs(x)^e)</td>\n",
       "      <td>SignedPower(x,e)</td>\n",
       "      <td>SignedPower(close-open, 0.5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>基本数学函数</td>\n",
       "      <td>取余函数</td>\n",
       "      <td>%</td>\n",
       "      <td>oi % 10</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        分类                                说明                公式  \\\n",
       "4   基本数学函数               符号函数，返回值为{-1, 0, 1}           Sign(x)   \n",
       "5   基本数学函数                             绝对值函数            Abs(x)   \n",
       "6   基本数学函数                              自然对数            Log(x)   \n",
       "7   基本数学函数                              对x取负                -x   \n",
       "8   基本数学函数                               幂函数                 ^   \n",
       "9   基本数学函数                            幂函数x^y          Pow(x,y)   \n",
       "10  基本数学函数  保持符号的幂函数，等价于Sign(x) * (Abs(x)^e)  SignedPower(x,e)   \n",
       "11  基本数学函数                              取余函数                 %   \n",
       "\n",
       "                              示例  \n",
       "4               Sign(close-open)  \n",
       "5                Abs(close-open)  \n",
       "6                Log(close/open)  \n",
       "7                         -close  \n",
       "8                      close ^ 2  \n",
       "9                   Pow(close,2)  \n",
       "10  SignedPower(close-open, 0.5)  \n",
       "11                       oi % 10  "
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 根据函数类型查询该类型下所有的函数\n",
    "dv.func_doc.search_by_type(\"数学函数\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分类</th>\n",
       "      <th>说明</th>\n",
       "      <th>公式</th>\n",
       "      <th>示例</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>基本数学函数</td>\n",
       "      <td>绝对值函数</td>\n",
       "      <td>Abs(x)</td>\n",
       "      <td>Abs(close-open)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       分类     说明      公式               示例\n",
       "5  基本数学函数  绝对值函数  Abs(x)  Abs(close-open)"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 根据函数描述查询可能符合该描述的所有的函数\n",
    "dv.func_doc.search_by_description(\"绝对值\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分类</th>\n",
       "      <th>说明</th>\n",
       "      <th>公式</th>\n",
       "      <th>示例</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>三角函数</td>\n",
       "      <td>正切函数</td>\n",
       "      <td>Tan(x)</td>\n",
       "      <td>Tan(close/open)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      分类    说明      公式               示例\n",
       "24  三角函数  正切函数  Tan(x)  Tan(close/open)"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 根据函数名查询该函数\n",
    "dv.func_doc.search_by_func(\"Tan\",precise=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分类</th>\n",
       "      <th>说明</th>\n",
       "      <th>公式</th>\n",
       "      <th>示例</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>三角函数</td>\n",
       "      <td>正切函数</td>\n",
       "      <td>Tan(x)</td>\n",
       "      <td>Tan(close/open)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>横截面函数 - 数据处理</td>\n",
       "      <td>将指标标准化，即在横截面上减去平均值后再除以标准差</td>\n",
       "      <td>Standardize(x)</td>\n",
       "      <td>Standardize(close/Delay(close,1)-1) 表示日收益率的标准化</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              分类                         说明              公式  \\\n",
       "24          三角函数                       正切函数          Tan(x)   \n",
       "56  横截面函数 - 数据处理  将指标标准化，即在横截面上减去平均值后再除以标准差  Standardize(x)   \n",
       "\n",
       "                                                示例  \n",
       "24                                 Tan(close/open)  \n",
       "56  Standardize(close/Delay(close,1)-1) 表示日收益率的标准化  "
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 根据函数名查询该函数 -模糊查询\n",
    "dv.func_doc.search_by_func(\"Tan\",precise=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### append_df\n",
    "\n",
    "- ` jaqs_fxdayu.data.Dataview.append_df(df, field_name, is_quarterly=False, overwrite=True) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 外部构造一个pandas.DataFrame,作为新增字段通过此方法添加到数据集中(更灵活的定义因子的方式)\n",
    "- 注：该方法通常只用于添加**日度**数据（设置is_qurterly=False），若通过该方法添加季度数据（is_qurterly=True）,则添加的数据无法自动对齐到日级别，也无法通过get_ts方法访问到。\n",
    "- 如需添加季度数据并将其自动对齐到日级别，请使用append_df_quarter方法\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|df |是  |pandas.DataFrame，日期为索引，品种为columns|待添加的数据|\n",
    "|field_name|是  |string|待新增的数据的字段名|\n",
    "|is_quarterly|否  |bool|是否是季度数据,默认False|\n",
    "|overwrite |否  |bool|若待新增的数据的字段名(field_name)与数据集中已有的字段冲突，是否覆盖。默认覆盖|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>symbol</th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601992.SH</th>\n",
       "      <th>601997.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603160.SH</th>\n",
       "      <th>603858.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170502</th>\n",
       "      <td>-0.02</td>\n",
       "      <td>-0.17</td>\n",
       "      <td>-0.15</td>\n",
       "      <td>-0.04</td>\n",
       "      <td>-0.04</td>\n",
       "      <td>-0.25</td>\n",
       "      <td>-0.10</td>\n",
       "      <td>-0.17</td>\n",
       "      <td>-0.15</td>\n",
       "      <td>-0.13</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.02</td>\n",
       "      <td>-0.07</td>\n",
       "      <td>-0.09</td>\n",
       "      <td>-0.12</td>\n",
       "      <td>-0.06</td>\n",
       "      <td>-0.19</td>\n",
       "      <td>-2.00</td>\n",
       "      <td>-0.49</td>\n",
       "      <td>-0.10</td>\n",
       "      <td>-0.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170503</th>\n",
       "      <td>-0.02</td>\n",
       "      <td>-0.39</td>\n",
       "      <td>-0.12</td>\n",
       "      <td>-0.08</td>\n",
       "      <td>-0.09</td>\n",
       "      <td>-0.16</td>\n",
       "      <td>-0.21</td>\n",
       "      <td>-0.15</td>\n",
       "      <td>-0.23</td>\n",
       "      <td>-0.17</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.03</td>\n",
       "      <td>-0.10</td>\n",
       "      <td>-0.54</td>\n",
       "      <td>-0.09</td>\n",
       "      <td>-0.06</td>\n",
       "      <td>-0.16</td>\n",
       "      <td>-0.58</td>\n",
       "      <td>-0.43</td>\n",
       "      <td>-0.03</td>\n",
       "      <td>-0.14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170504</th>\n",
       "      <td>-0.15</td>\n",
       "      <td>-0.17</td>\n",
       "      <td>-0.05</td>\n",
       "      <td>-0.11</td>\n",
       "      <td>-0.06</td>\n",
       "      <td>-0.30</td>\n",
       "      <td>-0.18</td>\n",
       "      <td>-0.10</td>\n",
       "      <td>-0.25</td>\n",
       "      <td>-0.04</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.01</td>\n",
       "      <td>-0.08</td>\n",
       "      <td>-0.42</td>\n",
       "      <td>-0.15</td>\n",
       "      <td>-0.04</td>\n",
       "      <td>-0.38</td>\n",
       "      <td>-1.68</td>\n",
       "      <td>-0.96</td>\n",
       "      <td>-0.18</td>\n",
       "      <td>-0.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170505</th>\n",
       "      <td>-0.13</td>\n",
       "      <td>-0.18</td>\n",
       "      <td>-0.36</td>\n",
       "      <td>-0.32</td>\n",
       "      <td>-0.09</td>\n",
       "      <td>-0.62</td>\n",
       "      <td>-0.12</td>\n",
       "      <td>-0.07</td>\n",
       "      <td>-0.29</td>\n",
       "      <td>-0.18</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.02</td>\n",
       "      <td>-0.18</td>\n",
       "      <td>-0.21</td>\n",
       "      <td>-0.47</td>\n",
       "      <td>-0.02</td>\n",
       "      <td>-0.34</td>\n",
       "      <td>-3.63</td>\n",
       "      <td>-1.41</td>\n",
       "      <td>-0.15</td>\n",
       "      <td>-0.03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170508</th>\n",
       "      <td>-0.05</td>\n",
       "      <td>-0.49</td>\n",
       "      <td>-0.21</td>\n",
       "      <td>-0.26</td>\n",
       "      <td>-0.14</td>\n",
       "      <td>-0.30</td>\n",
       "      <td>-0.17</td>\n",
       "      <td>-0.09</td>\n",
       "      <td>-0.64</td>\n",
       "      <td>-0.19</td>\n",
       "      <td>...</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-0.17</td>\n",
       "      <td>-0.82</td>\n",
       "      <td>-0.37</td>\n",
       "      <td>-0.02</td>\n",
       "      <td>-0.38</td>\n",
       "      <td>-2.49</td>\n",
       "      <td>-1.71</td>\n",
       "      <td>-0.39</td>\n",
       "      <td>-0.02</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 330 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol      000001.SZ  000002.SZ  000008.SZ  000009.SZ  000027.SZ  000039.SZ  \\\n",
       "trade_date                                                                     \n",
       "20170502        -0.02      -0.17      -0.15      -0.04      -0.04      -0.25   \n",
       "20170503        -0.02      -0.39      -0.12      -0.08      -0.09      -0.16   \n",
       "20170504        -0.15      -0.17      -0.05      -0.11      -0.06      -0.30   \n",
       "20170505        -0.13      -0.18      -0.36      -0.32      -0.09      -0.62   \n",
       "20170508        -0.05      -0.49      -0.21      -0.26      -0.14      -0.30   \n",
       "\n",
       "symbol      000060.SZ  000061.SZ  000063.SZ  000069.SZ    ...      601988.SH  \\\n",
       "trade_date                                                ...                  \n",
       "20170502        -0.10      -0.17      -0.15      -0.13    ...          -0.02   \n",
       "20170503        -0.21      -0.15      -0.23      -0.17    ...          -0.03   \n",
       "20170504        -0.18      -0.10      -0.25      -0.04    ...          -0.01   \n",
       "20170505        -0.12      -0.07      -0.29      -0.18    ...          -0.02   \n",
       "20170508        -0.17      -0.09      -0.64      -0.19    ...           0.00   \n",
       "\n",
       "symbol      601989.SH  601992.SH  601997.SH  601998.SH  603000.SH  603160.SH  \\\n",
       "trade_date                                                                     \n",
       "20170502        -0.07      -0.09      -0.12      -0.06      -0.19      -2.00   \n",
       "20170503        -0.10      -0.54      -0.09      -0.06      -0.16      -0.58   \n",
       "20170504        -0.08      -0.42      -0.15      -0.04      -0.38      -1.68   \n",
       "20170505        -0.18      -0.21      -0.47      -0.02      -0.34      -3.63   \n",
       "20170508        -0.17      -0.82      -0.37      -0.02      -0.38      -2.49   \n",
       "\n",
       "symbol      603858.SH  603885.SH  603993.SH  \n",
       "trade_date                                   \n",
       "20170502        -0.49      -0.10      -0.15  \n",
       "20170503        -0.43      -0.03      -0.14  \n",
       "20170504        -0.96      -0.18      -0.11  \n",
       "20170505        -1.41      -0.15      -0.03  \n",
       "20170508        -1.71      -0.39      -0.02  \n",
       "\n",
       "[5 rows x 330 columns]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = dv.get_ts('close') - dv.get_ts(\"high\")\n",
    "dv.append_df(df,\"close-high\",is_quarterly=False)\n",
    "dv.get_ts(\"close-high\").head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### append_df_quarter\n",
    "\n",
    "- ` jaqs_fxdayu.data.Dataview.append_df_quarter(df, field_name, overwrite=True) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 外部构造一个pandas.DataFrame,且DataFrame中为**季度数据**,作为新增字段通过此方法添加到数据集中(更灵活的定义因子的方式)\n",
    "> 与jaqs_fxdayu.data.Dataview.append_df(df, field_name, is_quarterly=True)不同之处在于:该方法为自动将所添加的季度也增加到日度数据中，相当于将数据对齐到日线为新数据df_daily后，再调用一次jaqs_fxdayu.data.Dataview.append_df(df_daily, field_name, is_quarterly=False)。这样可以方便加入季度，然后统一在日线周期下获取数据进行研究。\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|df |是  |pandas.DataFrame，日期为索引，品种为columns|待添加的数据|\n",
    "|field_name|是  |string|待新增的数据的字段名|\n",
    "|overwrite |否  |bool|若待新增的数据的字段名(field_name)与数据集中已有的字段冲突，是否覆盖。默认覆盖|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Query data - query...\n",
      "Query data - quarterly fields prepared.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>symbol</th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601992.SH</th>\n",
       "      <th>601997.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603160.SH</th>\n",
       "      <th>603858.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20160331</th>\n",
       "      <td>-11.4660</td>\n",
       "      <td>-18.4105</td>\n",
       "      <td>-10.4000</td>\n",
       "      <td>-18.7879</td>\n",
       "      <td>-8.1359</td>\n",
       "      <td>-6.3414</td>\n",
       "      <td>-3.7253</td>\n",
       "      <td>-0.3387</td>\n",
       "      <td>-7.6121</td>\n",
       "      <td>-12.4472</td>\n",
       "      <td>...</td>\n",
       "      <td>-10.4562</td>\n",
       "      <td>4.8409</td>\n",
       "      <td>-5.4368</td>\n",
       "      <td>-20.6642</td>\n",
       "      <td>-10.7903</td>\n",
       "      <td>-9.0602</td>\n",
       "      <td>-30.5938</td>\n",
       "      <td>-58.5293</td>\n",
       "      <td>-26.3598</td>\n",
       "      <td>-3.9513</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20160630</th>\n",
       "      <td>3.4734</td>\n",
       "      <td>4.5853</td>\n",
       "      <td>0.7098</td>\n",
       "      <td>0.9384</td>\n",
       "      <td>3.0494</td>\n",
       "      <td>-2.7715</td>\n",
       "      <td>1.3095</td>\n",
       "      <td>0.5910</td>\n",
       "      <td>2.0323</td>\n",
       "      <td>2.5554</td>\n",
       "      <td>...</td>\n",
       "      <td>3.4989</td>\n",
       "      <td>0.9899</td>\n",
       "      <td>4.2848</td>\n",
       "      <td>4.8958</td>\n",
       "      <td>3.8221</td>\n",
       "      <td>-0.2508</td>\n",
       "      <td>17.8033</td>\n",
       "      <td>5.4220</td>\n",
       "      <td>0.5424</td>\n",
       "      <td>2.1448</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20160930</th>\n",
       "      <td>3.4469</td>\n",
       "      <td>2.8231</td>\n",
       "      <td>3.9954</td>\n",
       "      <td>3.0741</td>\n",
       "      <td>2.2083</td>\n",
       "      <td>0.6739</td>\n",
       "      <td>1.6038</td>\n",
       "      <td>3.6994</td>\n",
       "      <td>2.6870</td>\n",
       "      <td>3.3735</td>\n",
       "      <td>...</td>\n",
       "      <td>2.9932</td>\n",
       "      <td>0.2131</td>\n",
       "      <td>0.8388</td>\n",
       "      <td>5.1189</td>\n",
       "      <td>3.1815</td>\n",
       "      <td>1.6016</td>\n",
       "      <td>18.4533</td>\n",
       "      <td>8.0545</td>\n",
       "      <td>9.7982</td>\n",
       "      <td>0.3639</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20161231</th>\n",
       "      <td>2.0210</td>\n",
       "      <td>11.4433</td>\n",
       "      <td>6.5921</td>\n",
       "      <td>0.5512</td>\n",
       "      <td>0.0144</td>\n",
       "      <td>2.5387</td>\n",
       "      <td>2.1093</td>\n",
       "      <td>-2.5432</td>\n",
       "      <td>-13.4652</td>\n",
       "      <td>9.3406</td>\n",
       "      <td>...</td>\n",
       "      <td>2.1099</td>\n",
       "      <td>-0.3445</td>\n",
       "      <td>1.0118</td>\n",
       "      <td>5.1804</td>\n",
       "      <td>1.4766</td>\n",
       "      <td>1.1263</td>\n",
       "      <td>1.5475</td>\n",
       "      <td>1.7371</td>\n",
       "      <td>-0.2593</td>\n",
       "      <td>2.2140</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170331</th>\n",
       "      <td>-9.3964</td>\n",
       "      <td>-19.0699</td>\n",
       "      <td>-11.4174</td>\n",
       "      <td>-4.4972</td>\n",
       "      <td>-5.7008</td>\n",
       "      <td>-0.1440</td>\n",
       "      <td>-1.5022</td>\n",
       "      <td>-1.7294</td>\n",
       "      <td>9.6676</td>\n",
       "      <td>-15.1272</td>\n",
       "      <td>...</td>\n",
       "      <td>-8.8577</td>\n",
       "      <td>-0.7407</td>\n",
       "      <td>-5.5384</td>\n",
       "      <td>-16.3442</td>\n",
       "      <td>-8.9765</td>\n",
       "      <td>-5.5680</td>\n",
       "      <td>-37.6522</td>\n",
       "      <td>-16.1615</td>\n",
       "      <td>-17.3611</td>\n",
       "      <td>-2.3932</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 330 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol      000001.SZ  000002.SZ  000008.SZ  000009.SZ  000027.SZ  000039.SZ  \\\n",
       "trade_date                                                                     \n",
       "20160331     -11.4660   -18.4105   -10.4000   -18.7879    -8.1359    -6.3414   \n",
       "20160630       3.4734     4.5853     0.7098     0.9384     3.0494    -2.7715   \n",
       "20160930       3.4469     2.8231     3.9954     3.0741     2.2083     0.6739   \n",
       "20161231       2.0210    11.4433     6.5921     0.5512     0.0144     2.5387   \n",
       "20170331      -9.3964   -19.0699   -11.4174    -4.4972    -5.7008    -0.1440   \n",
       "\n",
       "symbol      000060.SZ  000061.SZ  000063.SZ  000069.SZ    ...      601988.SH  \\\n",
       "trade_date                                                ...                  \n",
       "20160331      -3.7253    -0.3387    -7.6121   -12.4472    ...       -10.4562   \n",
       "20160630       1.3095     0.5910     2.0323     2.5554    ...         3.4989   \n",
       "20160930       1.6038     3.6994     2.6870     3.3735    ...         2.9932   \n",
       "20161231       2.1093    -2.5432   -13.4652     9.3406    ...         2.1099   \n",
       "20170331      -1.5022    -1.7294     9.6676   -15.1272    ...        -8.8577   \n",
       "\n",
       "symbol      601989.SH  601992.SH  601997.SH  601998.SH  603000.SH  603160.SH  \\\n",
       "trade_date                                                                     \n",
       "20160331       4.8409    -5.4368   -20.6642   -10.7903    -9.0602   -30.5938   \n",
       "20160630       0.9899     4.2848     4.8958     3.8221    -0.2508    17.8033   \n",
       "20160930       0.2131     0.8388     5.1189     3.1815     1.6016    18.4533   \n",
       "20161231      -0.3445     1.0118     5.1804     1.4766     1.1263     1.5475   \n",
       "20170331      -0.7407    -5.5384   -16.3442    -8.9765    -5.5680   -37.6522   \n",
       "\n",
       "symbol      603858.SH  603885.SH  603993.SH  \n",
       "trade_date                                   \n",
       "20160331     -58.5293   -26.3598    -3.9513  \n",
       "20160630       5.4220     0.5424     2.1448  \n",
       "20160930       8.0545     9.7982     0.3639  \n",
       "20161231       1.7371    -0.2593     2.2140  \n",
       "20170331     -16.1615   -17.3611    -2.3932  \n",
       "\n",
       "[5 rows x 330 columns]"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dv.add_field(\"roe\")\n",
    "roe = dv.get_ts_quarter('roe')\n",
    "df = roe.diff()\n",
    "dv.append_df_quarter(df, \"d-roe\")\n",
    "dv.get_ts_quarter(\"d-roe\").dropna().head() # 查询季度数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>symbol</th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601992.SH</th>\n",
       "      <th>601997.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603160.SH</th>\n",
       "      <th>603858.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170502</th>\n",
       "      <td>-9.3964</td>\n",
       "      <td>-19.0699</td>\n",
       "      <td>-11.4174</td>\n",
       "      <td>-4.4972</td>\n",
       "      <td>-5.7008</td>\n",
       "      <td>-0.144</td>\n",
       "      <td>-1.5022</td>\n",
       "      <td>-1.7294</td>\n",
       "      <td>9.6676</td>\n",
       "      <td>-15.1272</td>\n",
       "      <td>...</td>\n",
       "      <td>-8.8577</td>\n",
       "      <td>-0.7407</td>\n",
       "      <td>-5.5384</td>\n",
       "      <td>-16.3442</td>\n",
       "      <td>-8.9765</td>\n",
       "      <td>-5.568</td>\n",
       "      <td>-37.6522</td>\n",
       "      <td>-16.1615</td>\n",
       "      <td>-17.3611</td>\n",
       "      <td>-2.3932</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170503</th>\n",
       "      <td>-9.3964</td>\n",
       "      <td>-19.0699</td>\n",
       "      <td>-11.4174</td>\n",
       "      <td>-4.4972</td>\n",
       "      <td>-5.7008</td>\n",
       "      <td>-0.144</td>\n",
       "      <td>-1.5022</td>\n",
       "      <td>-1.7294</td>\n",
       "      <td>9.6676</td>\n",
       "      <td>-15.1272</td>\n",
       "      <td>...</td>\n",
       "      <td>-8.8577</td>\n",
       "      <td>-0.7407</td>\n",
       "      <td>-5.5384</td>\n",
       "      <td>-16.3442</td>\n",
       "      <td>-8.9765</td>\n",
       "      <td>-5.568</td>\n",
       "      <td>-37.6522</td>\n",
       "      <td>-16.1615</td>\n",
       "      <td>-17.3611</td>\n",
       "      <td>-2.3932</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170504</th>\n",
       "      <td>-9.3964</td>\n",
       "      <td>-19.0699</td>\n",
       "      <td>-11.4174</td>\n",
       "      <td>-4.4972</td>\n",
       "      <td>-5.7008</td>\n",
       "      <td>-0.144</td>\n",
       "      <td>-1.5022</td>\n",
       "      <td>-1.7294</td>\n",
       "      <td>9.6676</td>\n",
       "      <td>-15.1272</td>\n",
       "      <td>...</td>\n",
       "      <td>-8.8577</td>\n",
       "      <td>-0.7407</td>\n",
       "      <td>-5.5384</td>\n",
       "      <td>-16.3442</td>\n",
       "      <td>-8.9765</td>\n",
       "      <td>-5.568</td>\n",
       "      <td>-37.6522</td>\n",
       "      <td>-16.1615</td>\n",
       "      <td>-17.3611</td>\n",
       "      <td>-2.3932</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170505</th>\n",
       "      <td>-9.3964</td>\n",
       "      <td>-19.0699</td>\n",
       "      <td>-11.4174</td>\n",
       "      <td>-4.4972</td>\n",
       "      <td>-5.7008</td>\n",
       "      <td>-0.144</td>\n",
       "      <td>-1.5022</td>\n",
       "      <td>-1.7294</td>\n",
       "      <td>9.6676</td>\n",
       "      <td>-15.1272</td>\n",
       "      <td>...</td>\n",
       "      <td>-8.8577</td>\n",
       "      <td>-0.7407</td>\n",
       "      <td>-5.5384</td>\n",
       "      <td>-16.3442</td>\n",
       "      <td>-8.9765</td>\n",
       "      <td>-5.568</td>\n",
       "      <td>-37.6522</td>\n",
       "      <td>-16.1615</td>\n",
       "      <td>-17.3611</td>\n",
       "      <td>-2.3932</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170508</th>\n",
       "      <td>-9.3964</td>\n",
       "      <td>-19.0699</td>\n",
       "      <td>-11.4174</td>\n",
       "      <td>-4.4972</td>\n",
       "      <td>-5.7008</td>\n",
       "      <td>-0.144</td>\n",
       "      <td>-1.5022</td>\n",
       "      <td>-1.7294</td>\n",
       "      <td>9.6676</td>\n",
       "      <td>-15.1272</td>\n",
       "      <td>...</td>\n",
       "      <td>-8.8577</td>\n",
       "      <td>-0.7407</td>\n",
       "      <td>-5.5384</td>\n",
       "      <td>-16.3442</td>\n",
       "      <td>-8.9765</td>\n",
       "      <td>-5.568</td>\n",
       "      <td>-37.6522</td>\n",
       "      <td>-16.1615</td>\n",
       "      <td>-17.3611</td>\n",
       "      <td>-2.3932</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 330 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "symbol      000001.SZ  000002.SZ  000008.SZ  000009.SZ  000027.SZ  000039.SZ  \\\n",
       "trade_date                                                                     \n",
       "20170502      -9.3964   -19.0699   -11.4174    -4.4972    -5.7008     -0.144   \n",
       "20170503      -9.3964   -19.0699   -11.4174    -4.4972    -5.7008     -0.144   \n",
       "20170504      -9.3964   -19.0699   -11.4174    -4.4972    -5.7008     -0.144   \n",
       "20170505      -9.3964   -19.0699   -11.4174    -4.4972    -5.7008     -0.144   \n",
       "20170508      -9.3964   -19.0699   -11.4174    -4.4972    -5.7008     -0.144   \n",
       "\n",
       "symbol      000060.SZ  000061.SZ  000063.SZ  000069.SZ    ...      601988.SH  \\\n",
       "trade_date                                                ...                  \n",
       "20170502      -1.5022    -1.7294     9.6676   -15.1272    ...        -8.8577   \n",
       "20170503      -1.5022    -1.7294     9.6676   -15.1272    ...        -8.8577   \n",
       "20170504      -1.5022    -1.7294     9.6676   -15.1272    ...        -8.8577   \n",
       "20170505      -1.5022    -1.7294     9.6676   -15.1272    ...        -8.8577   \n",
       "20170508      -1.5022    -1.7294     9.6676   -15.1272    ...        -8.8577   \n",
       "\n",
       "symbol      601989.SH  601992.SH  601997.SH  601998.SH  603000.SH  603160.SH  \\\n",
       "trade_date                                                                     \n",
       "20170502      -0.7407    -5.5384   -16.3442    -8.9765     -5.568   -37.6522   \n",
       "20170503      -0.7407    -5.5384   -16.3442    -8.9765     -5.568   -37.6522   \n",
       "20170504      -0.7407    -5.5384   -16.3442    -8.9765     -5.568   -37.6522   \n",
       "20170505      -0.7407    -5.5384   -16.3442    -8.9765     -5.568   -37.6522   \n",
       "20170508      -0.7407    -5.5384   -16.3442    -8.9765     -5.568   -37.6522   \n",
       "\n",
       "symbol      603858.SH  603885.SH  603993.SH  \n",
       "trade_date                                   \n",
       "20170502     -16.1615   -17.3611    -2.3932  \n",
       "20170503     -16.1615   -17.3611    -2.3932  \n",
       "20170504     -16.1615   -17.3611    -2.3932  \n",
       "20170505     -16.1615   -17.3611    -2.3932  \n",
       "20170508     -16.1615   -17.3611    -2.3932  \n",
       "\n",
       "[5 rows x 330 columns]"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对应的日度数据\n",
    "dv.get_ts(\"d-roe\").dropna().head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  append_df_symbol\n",
    "\n",
    "- ` jaqs_fxdayu.data.Dataview.append_df(df, symbol_name, overwrite=False) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 外部构造一个pandas.DataFrame（含某个新品种的各个字段的信息）,作为新增品种通过此方法添加到数据集中\n",
    "- 目前，该方法只支持添加日线数据的信息，无法添加季度数据\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|df |是  |pandas.DataFrame，日期为索引，字段名为columns|待添加的数据|\n",
    "|symbol_name|是  |string|待新增的数据的品种名|\n",
    "|overwrite |否  |bool|若待新增的品种(symbol_name)与数据集中已有的品种冲突，是否覆盖。默认不覆盖|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Symbol [000001.SZ] is overwritten.\n"
     ]
    }
   ],
   "source": [
    "df = dv.get(\"000001.SZ\")\n",
    "df.columns = df.columns.droplevel(\"symbol\")\n",
    "dv.append_df_symbol(df=df,symbol_name=\"000001.SZ\",overwrite=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 删除数据\n",
    "\n",
    "### remove_field\n",
    "\n",
    "- ` jaqs_fxdayu.data.Dataview.remove_field(field_names) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 将指定字段从dataview中删除\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|field_names|是  |string|待删除的字段，用\",\"隔开|\n",
    "\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "print(\"open\" in dv.fields)\n",
    "dv.remove_field(\"open\")\n",
    "print(\"open\" in dv.fields)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### remove_symbol\n",
    "\n",
    "- ` jaqs_fxdayu.data.Dataview.remove_symbol(symbols) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 将指定品种从dataview中删除\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|symbols|是  |string|待删除的品种，用\",\"隔开|\n",
    "\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "print(\"000001.SZ\" in dv.symbol)\n",
    "dv.remove_symbol(\"000001.SZ\")\n",
    "print(\"000001.SZ\" in dv.symbol)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据落地\n",
    "\n",
    "### save_dataview\n",
    "\n",
    "- ` jaqs_fxdayu.data.Dataview.save_dataview(folder_path) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 将dataview中的数据保存到本地指定目录(folder_path)下\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|folder_path |是  |string|保存路径|\n",
    "\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os\n",
    "dataview_folder = './data'\n",
    "\n",
    "if not (os.path.isdir(dataview_folder)):\n",
    "    os.makedirs(dataview_folder)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Store data...\n",
      "Dataview has been successfully saved to:\n",
      "/home/xinger/Desktop/jaqs_plus/jaqs-fxdayu/docs/_source/data\n",
      "\n",
      "You can load it with load_dataview('/home/xinger/Desktop/jaqs_plus/jaqs-fxdayu/docs/_source/data')\n"
     ]
    }
   ],
   "source": [
    "dv.save_dataview(dataview_folder)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### load_dataview\n",
    "\n",
    "- ` jaqs_fxdayu.data.Dataview.load_dataview(folder_path) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 将数据从本地指定目录(folder_path)下加载到dataview中\n",
    "- 目前仅支持全部加载\n",
    "\n",
    "**参数：**\n",
    "\n",
    "|参数名|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|folder_path |是  |string|加载路径|\n",
    "\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dataview loaded successfully.\n"
     ]
    }
   ],
   "source": [
    "dv.load_dataview(dataview_folder)"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
